Eclipse error “Could not find or load main class”

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

    i had same problem but in my case firewall was blocking java directory path, make sure system firewall is allowing java directory path access.

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

    I had similar problem, my standalone java program was not working. I had other compilation error in my workspace in other unrelated java files. After removing all compilation errors I could run my standalone java program.

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

    If all the solution does not work for you, it may be caused by missing libraries:

    1. Right click your project, Build Path --> Configure Build Path --> Java Build Path --> Libraries
    2. Remove the missing libraries
    3. Go to your main class and run it
    0 讨论(0)
  • 2020-12-07 01:47

    I have checked all possible solutions including re-installation of JDK, eclipse as it worked for many people but unfortunately it didn't work for me. Also updated main class in pom.xml but it didn't help. It took my sleep away. I was trying different options and suddenly the magic happened when I checked this checkbox. It might be helpful for many people so thought of sharing

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

    If you are facing similar problem,it has to do with the "Run Configurations" not working properly in Eclipse.

    error1

    Please right clik on your java class containing the main method .Go to Run As-> Run Configurations and put the correct patrameters.Project should be the Project which contains the main class and Main class should be fuly qualified class name.See the snapshots below for clarity.It should wok fine then.Basically,you are creating a Run configuration and you can use that saved configuration for later use also.

    selecting run configurationparameters to be entered correctly

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

    Try to check first in the Problems window the errors you have. It is most likely it. Then check in the Configure Build Path... window under Order and Export for errors in jars and libraries (missing, duplicates, etc.).

    Fixing the problems will fix the class-loading issue.

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