Eclipse error “Could not find or load main class”

后端 未结 26 1489
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 01:31

I know there are many duplicates of this question, but I have looked at them all, and none of them have solved the issue.

I am trying to run a class that has a main

26条回答
  •  借酒劲吻你
    2020-12-07 01:43

    I came across the same problem. You might get this error in many situations like below.

    • Some dependency problem in your pom.xml
    • The run configuration may not have proper configuration. You might want to delete the existing one and create the new one like suggested in other answers.
    • You may want to try like mvn clean, mvn build and other options.
    • You may want to delete the project and import it again.
    • You may want to restart Eclipse and check your luck if it works.

    Here, the list of hit and trial goes on. Believe me the tool Eclipse is not that stupid. It is quite smart to find errors even at compile time. I tried all ways mentioned above, but none worked for me.

    The main problem which worked for me was JRE version which was somehow got set to default (JRE System Library [jre1.5]). I reset it to jre1.8.* which I had installed in my machine.

    I don't commit that this is only the solution to this problem but yes this could be one of the solution. So keep an eye on JRE version.

提交回复
热议问题