Eclipse cannot find the main class or cannot load the main class

Source: Internet
Author: User

Sometimes Eclipse will be crazy, good project so compile, even Hello world will report "can't find or can't load the main class " error, I have met several times, previously was lazy to delve into the direct reconstruction project, But the number of times have to delve into the next, now summed up several solutions, you can try according to their own situation.

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.

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.

Eclipse cannot find the main class or cannot load the main class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.