Tuesday, 8 September 2015

Eclipse “Error: Could not find or load main class”

Some time eclipse not run any java file and give exception like
"Error: Could not find or load main class"

Bellow are few solution :

Solution 1 )
  • went to run configurations: - run->run configurations
      In the Classpath tab:
  • Select Advanced
  • Add where Eclipse usually put the *.class for the projects, which is in bin. So I added the bin directory for the project.
Solution 2)
   
  • Project -> Clean will remove any existing class files and completely rebuild the project.
Solution 3)

It seems that the class is not compiled by Eclipse.
Few pointers could be-
  1. Check if the .class file exists in your output folder.To know your output folder Right Click on Project->Properties->Java Build Path(Check at bottom).
  2. Check if Project->build Automatically is checked in the menu.
  3. Check if the HelloWorld class is in src folder or not.Right Click on Project->Properties->Java Build Path(Check source tab).

No comments:

Post a Comment