0

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.

4
  • Try to clean your project and then re-build. Commented Sep 9, 2013 at 16:59
  • Some heuristics: restart the JVM, remove all the libraries and add them afresh. Commented Sep 9, 2013 at 16:59
  • if you have solved your own problem, you can post your own answer and accept it, so that the question is flagged as answered. Commented Sep 9, 2013 at 17:56
  • Sure- I just need to be absolutely sure and also confirm the exact reason for the issue. I will add an answer once I'm sure - thank you. Commented Sep 9, 2013 at 17:58

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

classpath is fine. I think I found the issue (or at least how to resolve it). Thanks for sharing!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.