java - Editor does not contain a main type [duplic

2019-06-26 10:50发布

问题:

Possible Duplicate:
Eclipse error: “Editor does not contain a main type”

I am currently coding a server socket application where you can connect to several clients via a thread pool.

But when I want to compile the main I get:

Why do I get that? I still have a main in my mainServer.java

I appreciate your answer!!!

回答1:

Make sure your Launch Configuration is pointed to ServerMain, and if it isn't, make sure you do Run As > Java Application.

Otherwise you could try a Project > Clean

Also some more questions that deals with this that could be helpful, Eclipse error: "Editor does not contain a main type" Editor does not contain a main type



回答2:

Please make sure your project source (src) folder is on the build path. If not, the main() method may not be included in your project. You can follow the below steps to verify your source path settings:

  • Right click on your project from Package Explorer.
  • Select Properties (ALT + Enter)
  • Go to Java Build Path Click on Source tab & check whether the source folder is on the build path

Once the verification is completed, you may please close your project & reopen it. Then, you should be able to right click on a class file with a main method (ServerMain.java in your case) and run it.



回答3:

You can configure your main class (has to be static to my understanding) in the properties of the project.

Make sure it points to the right location.

http://protegewiki.stanford.edu/images/2/24/Protege41InEclipseRunnableMainTab.png



回答4:

I have also faced this issue some times, i use workaround for this.
go to package explorer and then go to desired class(class under .java file), right click and run as java application