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