Sunday, April 03, 2011

Eclipse: Selection Does Not Contain A Main Type

If you are having a problem launching your project as a Java Application in Eclipse due to the error: "Selection does not contain a main type" a simple work around is to simply create a new Java project and copy your class files into the source folder of the new project.

You can also create a new Java project in Eclipse and change the build path to point to your existing source folders. Right click on the project and select "Java Build Path". Click on the "Source" tab. Remove any folders you don't want and point to your existing source folders.

Then your Eclipse Java project configuration should be accurate (without having to figure out the problem with it - which is the other option) and you should be able to right click on a class file with a main method and run it.

Related posts:

http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg04471.html

http://stackoverflow.com/questions/4252472/java-launch-error-selection-does-not-contain-a-main-type