Java launch error selection does not contain a main type

后端 未结 3 1866
生来不讨喜
生来不讨喜 2020-12-17 10:00

I am a total newbie in Java and Eclipse. I googled for lots of help but still confused. From Eclipse I click run then choose Java application and I get this error immediatel

相关标签:
3条回答
  • 2020-12-17 10:29

    Create a new project and make the build path to point to the existing source folders. This will resolve the "Selection does not contain a main type" error.

    0 讨论(0)
  • 2020-12-17 10:37

    You cannot define the main method as you do in C++.

    For the Java interpreter, the main method must always be public and static. So you need to change your main method signature to

    public static void main(String args[])
    

    Try this, and feel free to ask further. :-)

    0 讨论(0)
  • 2020-12-17 10:42

    I also experienced this problem and could solve it. The solution was not mentioned yet.

    In my case I'm working in Eclipse with Xtend and I converted the project to maven. After that there was a source-exclusion entry in your classpath file:

    <classpathentry excluding="**" kind="src" output="target/classes" path="xtend-gen">
    

    Then you just need to delete this line and do a clean build.

    0 讨论(0)
提交回复
热议问题