Java Eclipse Oxygen - 项目未构建,因为其构建路径不完整

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47205880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 02:35:12  来源:igfitidea点击:

Eclipse Oxygen - The project was not built since its build path is incomplete

javaandroideclipse

提问by user123456789

I just installed Eclipse Oxygen and tried to open an existing project into the workbench but I get this error:

我刚刚安装了 Eclipse Oxygen 并尝试将现有项目打开到工作台中,但出现此错误:

The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project

该项目未构建,因为其构建路径不完整。找不到 java.lang.Object 的类文件。修复构建路径然后尝试构建这个项目

I tried right clicking on the project - went to Properties - Java Build Path - Libraries - Add Library - JRE System Library and selected Workbench default JRE (jre1.8.0_60).

我尝试右键单击项目 - 转到属性 - Java 构建路径 - 库 - 添加库 - JRE 系统库并选择 Workbench 默认 JRE (jre1.8.0_60)。

I then cleaned and rebuilt the project but it then causes more errors to come up like:

然后我清理并重建了项目,但它会导致更多错误出现,例如:

ActionBar cannot be resolved to a type
Activity cannot be resolved to a variable
AdapterView cannot be resolved to a type
ArrayAdapter cannot be resolved to a type

回答by Ash_s94

Are you using Maven? If so,

你在使用 Maven 吗?如果是这样的话,

  1. Right-click on the project, Build Path and go to Configure Build Path
  2. Click the libraries tab. If Maven dependencies are not in the list, you need to add it.
  3. Close the dialog.
  1. 右键单击项目,构建路径并转到配置构建路径
  2. 单击库选项卡。如果 Maven 依赖项不在列表中,则需要添加它。
  3. 关闭对话框。

To add it: Right-click on the project, Maven → Disable Maven Nature Right-click on the project, Configure → Convert to Maven Project.

添加它: 右键单击​​项目,Maven → 禁用 Maven Nature 右键单击​​项目,配置 → 转换为 Maven 项目。

And then clean

然后清洗

Edit 1:

编辑1:

If that doesn't resolve the issue try right-clicking on your project and select properties. Select Java Build Path → Library tab. Look for a JVM. If it's not there, click to add Library and add the default JVM. If VM is there, click edit and select the default JVM. Hopefully, that works.

如果这不能解决问题,请尝试右键单击您的项目并选择属性。选择 Java 构建路径 → 库选项卡。寻找 JVM。如果不存在,请单击添加库并添加默认JVM。如果 VM 存在,请单击编辑并选择默认的 JVM。希望,这有效。

Edit 2:

编辑2:

You can also try going into the folder where you have all your projects and delete the .metadatafor eclipse (be aware that you'll have to re-import all the projects afterwards! Also all the environment settings you've set would also have to be redone). After it was deleted just import the project again, and hopefully, it works.

您也可以尝试进入您拥有所有项目的文件夹并删除.metadatafor eclipse(请注意,之后您必须重新导入所有项目!此外,您设置的所有环境设置也必须是重做)。删除后只需再次导入项目,希望它可以工作。

回答by Thracian

I'm also using Eclipse Oxygen, migrated from Mars. I faced the same error. I deleted .metadata, .recommendersfolders and added projects from archive and issue is solved. I also use Android Studio but i like Eclipse much more.

我也在使用从火星迁移的 Eclipse Oxygen。我遇到了同样的错误。我删除.metadata.recommenders从存档和问题的文件夹,并添加项目就解决了。我也使用 Android Studio,但我更喜欢 Eclipse。

回答by zee

Here is what made the error disappear for me:

这是使我的错误消失的原因:

Close eclipse, go to the terminal and run:

关闭 eclipse,进入终端并运行:

$ mvn clean eclipse:clean eclipse:eclipse

回答by Thomas P.

At my system the Java Runtime JAR file jrt-fs.jarwas not found because it was in the wrong directory. This file should be located in the "lib" subfolder. If you installed Java at "C:\Temp\java" the file should be here at C:\Temp\java\lib\jrt-fs.jar .

在我的系统中,未找到Java 运行时 JAR 文件jrt-fs.jar,因为它位于错误的目录中。此文件应位于“lib”子文件夹中。如果您在“C:\Temp\java”安装了 Java,则该文件应该位于 C:\Temp\java\lib\jrt-fs.jar 。

These are the steps to make jrt-fs.jaravailable to Eclipse:

这些是使jrt-fs.jar可用于 Eclipse的步骤:

  1. Window / Preferences -> the "Preferences" Window opens
  2. Select in the left menu: Java / Installed JREs
  3. Press the [Add...] Button -> A window opens
  4. Select "Standard VM" - The window "JRE Definition" opens.
  5. Enter your path information:
  6. JRE home = "C:\Temp\java"
  7. JRE name = "MyJRE"
  8. Select [Add External JARs...] to link the jrt-fs.jar
  9. JRE system libaries: "C:\Temp\java\lib\jrt-fs.jar"
  1. 窗口/首选项 ->“首选项”窗口打开
  2. 在左侧菜单中选择:Java / Installed JREs
  3. 按 [添加...] 按钮 -> 一个窗口打开
  4. 选择“标准 VM” - 窗口“JRE 定义”打开。
  5. 输入您的路径信息:
  6. JRE 主页 = "C:\Temp\java"
  7. JRE 名称 = "MyJRE"
  8. 选择[Add External JARs...]链接jrt-fs.jar
  9. JRE 系统库:“C:\Temp\java\lib\jrt-fs.jar”

It worked for me with OpenJDK12 and Eclipse 2019-09 (4.13.0). Eclipse reported me this error:

它适用于 OpenJDK12 和 Eclipse 2019-09 (4.13.0)。Eclipse 向我报告了这个错误:

The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project

回答by Abinash

I had faced this problem. I added the C:\Users\Office 2\android-sdks\platforms\android-19\android.jar to the Java Build Path's Library. And the project started to run again. The problem occurred due to my carelessness. Yesterday night I was updating the Android SDK, and at the same time I tried to run the project, while the SDK Manager was uncompressing the system image. The Project couldn't start and the error occurred.

我曾经遇到过这个问题。我将 C:\Users\Office 2\android-sdks\platforms\android-19\android.jar 添加到 Java Build Path 的库中。然后项目又开始运行了。问题是由于我的粗心造成的。昨天晚上我正在更新Android SDK,同时我尝试运行该项目,而SDK Manager正在解压缩系统映像。项目无法启动并发生错误。

I tried all the methods given by others. But nothing worked. It solved when I added the android.jar to the library.

别人给的方法我都试过了。但没有任何效果。当我将 android.jar 添加到库时它解决了。

I guessed it that android library is missing. not the Java, when I saw the errors only at the android methods and imports. But when I read the posts, I got confused and wasted some time trying wrong way.

我猜是缺少 android 库。不是 Java,当我只在 android 方法和导入中看到错误时。但是当我阅读这些帖子时,我感到困惑并浪费了一些时间尝试错误的方法。

回答by Shakthifuture

I had faced same issue and tried different solutions, I have reinstalled my JDK 11, after that the issue gets resolved.

我遇到了同样的问题并尝试了不同的解决方案,之后我重新安装了 JDK 11,问题得到解决。