Eclipse can't find / load main class

前端 未结 20 2225
猫巷女王i
猫巷女王i 2020-12-05 04:40

My Eclipse (Indigo) was running just fine. I created a simple class Hello. It is placed in package cont in the folder ch13. However

20条回答
  •  余生分开走
    2020-12-05 05:01

    Note: This worked in the past and I received many up votes. Perhaps this is not a solution anymore - but it once was - as the eclipse version was indicated.


    Problem

    This can also be caused by a Java Build Path Problem.

    In my case, I had a an error:

    A cycle was detected in the build path of project {project}. The cycle consists of projects {x, y, z}.

    This can occur when you include other projects in the build path of the project you wish to run. In fact, all the projects will fail to run with the error Could not find the main class: Example.class


    Solution

    Open

    Windows -> Preferences -> Java-> Compiler -> Building -> Build Path Problems

    Uncheck the Abort build when build path errors occur toggle

    This seems like a can of worms if you end up with other build path errors I image. So use with caution.


    • Note: This only works if you have a "cycle error". This error message can be found in the "Markers" tab

    I found the solution to this here


    Info

    • Java 1.8.0_152
    • Eclipse Photon (June 2018)

提交回复
热议问题