Eclipse "Error: Could not find or load main class"

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 enter image description here


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

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


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