Eclipse error “Could not find or load main class”

后端 未结 26 1449
爱一瞬间的悲伤
爱一瞬间的悲伤 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:33

    I just encountered the same problem as yours and I followed Kumar's directions and it worked out. One thing to add: you need to make sure that after you go to the correct main class, check the "Classpath" and your project name should be existed under the "User Entries". If not, add your project to the directory then you're good to go.

    0 讨论(0)
  • 2020-12-07 01:35

    you should add bin folder - run->run Configuration tab classpath advanced button - add folder - choose bin folder (yourproyect/bin)

    0 讨论(0)
  • 2020-12-07 01:35

    Follow these steps :

    1)Delete your current run configuration. 2)Go to the main class and run it by right clicking the mouse-->Run As-->Java Application.

    Then you will see an auto generated new run configuration.

    0 讨论(0)
  • 2020-12-07 01:35

    I had the same issue and I could not start any project with main() methods.

    I tried almost everything mentioned above, but it turned out that I had a little mistake in my pom.xml file.

    You can check this file too!

    0 讨论(0)
  • 2020-12-07 01:36

    I too faced same problem.

    Simple solution is : delete project( not source files please). close eclipse--> go to project folder-- > remove classpath and project file .

    then open Eclipse and create project in same location

    0 讨论(0)
  • 2020-12-07 01:36

    I also had the same issue and was getting "Error: Could not find or load main class ...."

    I solved it as follows:

    1. Right clicked on my Java main class > Run As > Run Configurations.

    2. In the resultant popup box and Under Java Application your java file name would be selected mode... if not select it

    3. On the right side of the same box and under Classpath tab Clear all Bootstrap and User Entries (if any)
    4. Under Bootstrap Entries Click Advanced Button > Select Add Library Radio and click OK. In next "Add Library" box Select JRE System Library and provide your correct JRE location and click Finish. (If it is not visible then u have to add it by clicking Installed JRE > Add button). Now you can see JRE System Library under BootStrap Entries

    5. Next User Entries > Click Add Projects Button > And then under Project Selection box check on your Project name > OK

    The main java file should now work. Hope this may help someone who would be facing similar issues.

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