I have a project in eclipse on my laptop that I pushed to Git https://github.com/chrisbramm/LastFM-History-Graph.git
It works fully on my laptop and runs/builds without a problem but on my desktop it doesn't Eclipse gives the error
Error: Could not find or load the main class lastfmhistoryguis.InputPanel
I've tried building the project from:
Project>Build Project
But nothing happened. I've set the PATH
variables on this computer to JRE6, JRE7 and JDK 1.7.0 even though these aren't set on my laptop.
I did have Jar file (last.fm-bindings-0.1.1.jar) that was in my .classpath
file that was in C:\Users\Chris\Downloads folder on my laptop hence it wasn't included in the git tree which I recently brought into the project folder and committed ,but I'm not sure whether I have done it right.
Would this also be causing a problem but there isn't a main argument in there.
I can't work out now, what I need to check/change.
If you create a java class with
public static void main(String[] args)
, Eclipse will run that main method for you by right clicking on the file itself, or on the file in the project explorer, then choosing:Once you do this, Eclipse stores information about your class, so you can easily run the class again from the Run As menu (Green Play Button on the toolbar) or from the Run Configurations dialog.
If you subsequently MOVE the java class (manually, or however), then again choose
from the new location, Eclipse will run the original stored configuration, attempt to invoke this class from its original location, which causes this error.
For me, the fix was to go to the run configurations, (Green Play Button -> Run Configurations) and remove all references to the class. The next time you run
Eclipse will write a new configuration for the moved class, and the error will go away.
I had this error. It was because I had
static void main(String[] args)
instead of
public static void main(String[] args)
I spent nearly an hour trying to figure that out.
Note: The only difference is that I didn't declare
main
to bepublic
In your classpath you're using an absolute path but you've moved the project onto a new machine with quite possibly a different file structure.
In your classpath you should therefore (and probably in general if you're gonna bundle JARS with your project), use relative pathing:
In your .classpath change
to
Check the workspace error log (Windows-> Show View -> Error log). If you see any of the jar's imported is corrupted, remove the corresponding repository folder and re-import again.
Happened to me when I changed installed JREs to JDK7 instead of JRE7. Everything compiled but I couldn't run anything from Eclipse "eclipse-error-could-not-find-or-load-main-class"
Fix; going back to previous JRE7.
If You are using eclipse then the following steps will solve your problem: