ali haider
ali haider

Reputation: 20182

issue with classpath in eclipse project

Most likely pilot error. I have a project which was building correctly but not anymore. I have checked the build and run path settings and could not find anything incorrect (neither in the classpath file). I am posting relevant content below - any suggestions to troubleshoot this issue will be quite welcome (other than unfreezing my brain). All my jar files are in the lib directory and are referenced as such - however, when I run the project, I get a "Could not find or load main class" exception. I have a public static void main(String[] args) method in a class in the project (there is no other main method in the project).

I have a main class specified in the run configurations (this class contains the main method).

Update: I was able to recreate the project as a new eclipse project and build/run cleanly. Trying to figure out what caused the issue (still unresolved) with the previous project.

Second Update I had added a JRE directory in the project but I thought it was not being referenced. Removing it from the parent directory fixed the issue with running the project. It was the same version as the default JRE on the system/eclipse.

Upvotes: 0

Views: 75

Answers (2)

ali haider
ali haider

Reputation: 20182

I had a JRE directory in my project (which I had added earlier for testing) - this was the same JRE (I believe) that was being used by Eclipse/system. Simply removing the JRE allowed the project to run correctly. I will reconfirm later whether there was a minor version mismatch between the JRE's somehow. Hope it helps others.

Upvotes: 1

upog
upog

Reputation: 5521

Have you checked .classpath file is correct. Since your code is not compiling you wont generating .class file Hence you would be getting "Could not find or load main class". If possible try clean and build trough ant script

Upvotes: 0

Related Questions