sometimes Eclipse will be insane, and project will not compile, and even Hello world will report " the main class could not be found or could not be loaded "The mistake, I have met several times, was not bothered to delve into the direct reconstruction project, but encountered a number of times have to delve into the next, now summed up several solutions, everyone according to their own situation one by one to try.
1, because the. java file is not within the SRC path of the project, that is, the source code is not compiled by Eclipse, the bytecode does not exist can not be run on the project name right---Builder path, Configure Build path, Select the source panel and click Add Folder to add the upper directory of the package path where the sources are located, and if you are writing two classes in a file, when you right-click the run as Java appication, you want to include the cursor on the class that includes the main method.
In a nutshell, a jar bag with a red fork in it
2, the quickest solution is to open the class with the main function, CTRL +a (select All)---> Ctrl +x (CUT)-----> Ctrl+s (SAVE)---> Close----> Then open--->ctrl +c (paste)-- -->ok; One word is stick it out and stick it in.
3. Rebuilding project is OK.
4 . In the Java Build path of the project, the libraries may not be available in a jar package, showing a red fork. This indicates that the system cannot find this jar file, remove or reload the jar.
5, if not, we directly under the cmd Javac and then Java run try, if this all error, it is your JDK or OS environment has a problem.
Workaround for the main class cannot be found under eclipse or cannot be loaded