Programs written in Java programming language need a main() method to be run/executed because it is where the program execution begins. Occasionally when you run a Java program, you might see the error "Could not find or load main class" . You get this error because you are incorrectly trying to run the main() inside the class using java command. For example, If your source code name is HelloWorld.java, your compiled code will be HelloWorld.class. You will get that error if you call it using:
java HelloWorld.class
Instead, use this:
java HelloWorld
Other reasons to occur this error is :
File Extension
Wrong package
Invalid Classpath
Wrong Class Name
Programs written in Java programming language need a main() method to be run/executed because it is where the program execution begins. Occasionally when you run a Java program, you might see the error "Could not find or load main class" . You get this error because you are incorrectly trying to run the main() inside the class using java command. For example, If your source code name is HelloWorld.java, your compiled code will be HelloWorld.class. You will get that error if you call it using:
java HelloWorld.class
Instead, use this:
java HelloWorld
Other reasons to occur this error is :
File Extension
Wrong package
Invalid Classpath
Wrong Class Name
net-informations.com/java/err/main...
thanks for the nice explanation!