Answer the question
In order to leave comments, you need to log in
How to get rid of "Could not find or load main class helloworld" Java error?
Maybe someone knows how to solve this problem ..
When writing a program in eclipse, everything compiles and works fine, but when I try to run the program through the command line, the error "Could not find or load main class helloworld"
For example, I wrote "Hello World!"
package ru.sers.helloworld;
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Answer the question
In order to leave comments, you need to log in
At startup, you also need to specify the package here
and maybe here
Are class names case sensitive? helloworld and HelloWorld different classes
encountered a similar error Error: Could not find or load main class sample.Main when experimenting with Intellij Idea c Kotlin+
JavaFX the following inconvenient "crutch": If this error occurs, delete the production subdirectory (with all the contents of the previous build results in ) in the out directory.
After that, it is successfully built, but often only 1 time (then again .. and again delete this directory).
How radically to treat did not find. Who will offer what?
If you created the main class with the Main method in the package, then you need to go to the directory with the main project in the terminal and type the command == for example (java com.javacourse.se.lesson1.Main)
terminal: PS D:\Java_Projeckt_intellij2020_2_3\out\production\ HelloWorld > java com.javacourse.se.lesson1.Main
I've been struggling with this issue for 3 days! Rummaged everything. I consider it my duty to share.
I started learning Java from the book by Yakov Fine. The program was compiled from the command line. I didn't go to Eclipse IDE. I climbed into the Patch and CLASSPATCH settings, deleted my folders from the Workspace Directory and returned it again and somehow perverted it.
As a result, according to a 5-year-old video https://youtu.be/mDyXljx8dMI (Java Basics. Lesson 6: The first Java program in Eclipse (Vladimir Vysokomornyi)) replaced the default library in Eclipse - JRE with JDK. And it worked. True, the simplest program thinks for 15 seconds.
In an open project, I press File / Properties /, then I selected Java Build Path on the left side, and the Libraries tab in the central part.
Selected the JRE folder and clicked the Remove button. Selected the inscription Modulepath, only after that the button on the right Add Library became active. I press. I select the JRE System Library, then the Next> button, activate the Alternative JRE label and select jdk-15.0.1 from the drop-down list.
I click Finish and Apply and Close.
Only in order for jdk-15.0.1 to appear in the drop-down list, you first had to include this library, as in the video tutorial. I did not connect, it was written The JRE name is already in use (already in use).
Good luck and patience
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question