Eclipse solves the method of editor does not contain a main type

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/huazhangena/article/details/7349044

Written in front of the words: I also appear this problem, but the solution and the content of the forwarding is not the same, the same principle, I am right-click Src--build path--use as source folder, estimated that previously deleted some of the project, If there are many errors for other folders, do not worry, remove the source folder, remember to restart after the run, and the package is estimated to re-rebuild source.

Today with Eclipse, when you plan to run a class with the main function, an error box appears in editor does not contain a main type.

Baidu, quickly solve the problem: The original class package is not added to the build path.

Workaround: In the Package Explorer on the left, right-click the top-level directory--build Path--use as source folder for this class. This will solve the problem.

Reopen class, run again, OK.

-----------------------------------------------------
Additions and explanations:

Hey, all right. Explain it a little more briefly.


Look at this picture, SRC is in the build path (carefully observe the icon of SRC)
In contrast, resource is just a normal folder, not a build path (the icon is not the same as SRC?). )
Then I resource under the new folder and file, compare, the package and folder icons are not the same.

Now, I'm going to add the resource to the build path. (method is to right-click Resource--build path--use as source folder)

This way, both SRC and resource are in the build path.

Finally, explain what is called "in Build Path"? As you can see, in Eclipse, the class under build path can be compiled and run, and the configuration file under Build path can be read and written directly by the class as a relative path.

Eclipse solves the method of editor does not contain a main type

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.