Eclipse appears could not find the main class, mostly due to improper JDK versions used.
Exception reason: When you use the Eclipse tool to create a new Java project named MyProj, and in which a simple Java class is created to run the test, Eclipse throws the name "could not find" main class. Program'll exit. " The exception.
Verification reason: There are multiple JDK versions on this machine (that is, 1.4 and 1.5 two versions), resulting in an exception because the default JDK version of MyProj is inconsistent with the JDK version used by the Eclipse tool.
Workaround: Make the MyProj default JDK version consistent with the JDK version used by the Eclipse tool. The specific treatment method is as follows.
1, first check the JDK version used by Eclipse. Window--> Preferences--> Java--> installed JREs. View the currently used JDK version in the installed JREs window on the right (JDK1.4 is set up on this machine).
2, mouse click MyProj Project, so that the mouse focus on the project, and then click the menu bar Project--> Properties--> Java Compiler. In the JDK compliance on its right, see if the JDK version in the compiler compliance level is consistent with the JDK version viewed above, and if it is inconsistent, keep it consistent ( The default version of the project in this machine is 5.0, and its version number is modified to 1.4.
Note: If the column is dead Gray and cannot be edited, click on the above name to enable project specific settings checkbox to modify the JDK version
There are several places under eclipse that need to use JRE. The first is compiler use, the second is development use, and the third is run-time use.
Unfortunately, these three are configured separately, and your problem is that there is a version conflict between the three packages in eclipse.
You can check the eclipse's JRE configuration process online. Try to replace the eclipse's own JRE with the official version, preferably in the same edition.