简体   繁体   中英

eclipse doesn't compile the project

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?

Maybe Eclipse's workspace files have become corrupted. Restart Eclipse and choose a new workspace folder (or choose Switch workspace from the menu). Then import the project files into a new project.

Try deleting the run configuration and remaking.

If that doesn't work, open the class, ctrl+f11 to run. That will force Eclipse to update its classpaths & rebuild its main indexes.

To delete the configuration: - Menu -> Run -> Run Configurations. - Select your configuration - Press delete or use the delete icon

如果您正在使用maven,这可能会解决它:右键单击您的项目 - > Maven - >更新项目..(或alt + F5),选择您的项目,确保选中“从本地文件系统刷新工作区资源”并单击好。

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.

项目属性 - >构建器

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.

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.

尝试刷新然后清理项目。

My eclipse project has similar issue though the error appeared slightly different. I imported a third party java project into Eclipse, with Project > Build Automatically checked, do a Project > Clean..., no classes were generated in the output bin folder. Tried different options, no luck.

I noticed a red exclamation mark at the top left corner of the project name.

在此输入图像描述

Right click on project name, Properties > Java Build path, I saw "Build path entry is missing: cci/src". Manually created src folder, the red exclamation mark gone. Do a Project > clean..., project compilation successful

PS The eclipse project is not properly organized, there are no code under src folder. I suspected src folder went missing while checked in by original author since there are no code there.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM