eclipse doesn't compile the project

Viewed 55430

I had running project opened in eclipse. After an accidental restart of windows, now when I open the eclipse I see my project is marked with a little red cross. Now when I run the main method I get a java.lang.NoClassDefFoundError.

I have tried restarting eclipse, Project -> Clean but it doesn't solve the problem.

When I checked the project directory, inside 'target' folder there are no compiled .class files. I tried building the project but I can't get the compiled class files, which is the reason for the error.

How do I solve this?

8 Answers

I tried all the solutions here, but here's what worked for me.

  1. First, remove the project from eclipse.

  2. Then, in your project folder, delete the 2 files that eclipse creates. They're hidden, but they're called .project and .classpath.

  3. Finally, add the project back into eclipse and eclipse will recreate those 2 files and a new configuration for your project.

My specific issue was that it a project that was missing a Java Builder because it thought it was a scala project. The only way for me to reset this was by removing the project, deleting the 2 files, and adding it back in.

Was having the same problem and finally found the glorious hint here. In my project there is one *.scala File and Eclipse Neon is incompatible with the Scala IDE, thus there is no builder for scala and the whole project is not built.

Project Properties -- > Builders

After removing the Scala file and the Scala Package from the linked Libraries )Project Properties --> Build Path --> Libraries) and afterward re-adding the Java Builder (no idea why this one went missing, but here's a useful help on how to add the Java builder when missing), the project could be built and run again.

For me the problem is in missing jars,the jars were added first and the location of those jars where changed after. So When I correctly added all the required jars again to the build path, it starts to build project correctly.

Related