The correct way to compile and execute this class is :Į:\java-examples\src> javac com\howtodoinjava\core\basic\MainClass.javaĮ:\java-examples\src> java .MainClass If we want to execute the main() method in MainClass, we must use the full class name, including package name, in the java command. java file has been created, and try to run the example, we will get this error.Į:\java-examples\src\com\howtodoinjava\core\basic> javac MainClass.javaĮ:\java-examples\src\com\howtodoinjava\core\basic> java MainClassĮrror: Could not find or load main class MainClass If we try to navigate to the location where the. We are trying to execute this class using the command line. Reason for error – could not find or load main classĬonsider the below Java class which has a main() method. We get this error because we are incorrectly trying to run the main() inside the class using java command. Hello world application) from the system console. We may get this error ( Could not find or load main class) while running the Java class (e.g.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
May 2023
Categories |