Fixing this issue might be hard, especially if you’re new to Java, but hopefully this guide should be able to help you with this problem.

How can I fix could not find or load main class?

1. Check the class name

Note: The most common mistake is when you declare a class name in the wrong format when running it from the compiler. Also, the correct command to run a .class file generated by the Java compiler is java You don’t have to provide the .class extension: java HelloWorld.class. This is is an obvious solution, but it might work if you’re getting Could not find or load main class in Eclipse.

2. Check the package name

Note: If your class is included in a package, then to run it you must provide its fully qualified name. Also, when you create a package, you actually create a folder structure like C:\Java\classes\packagename\classname.java After checking your code, the Could not find or load main class Java message should be gone.

3. Remove class references

If you go now to Run As and select Java application, Eclipse will write a new configuration for the class you moved. Therefore, it won’t display the error anymore. These are some simple guidelines, and they should come in handy if you encounter Could not find or load main class in Eclipse. Troubleshooting and debugging is an important part of any Java application you create. This guide provides you solutions for a common error you might meet while running a java class. If you run it from a Linux terminal and encounter this error, the first two solutions will work for you too. Check the class name and the directory from where you run your program.

SPONSORED Name * Email * Commenting as . Not you? Save information for future comments
Comment

Δ