Eclipse 中未绑定的类路径容器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2083461/
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
Unbound classpath container in Eclipse
提问by Jessica
I have checked out a project using Subversive for Eclipse and I am getting the following errors:
我已经使用 Subversive for Eclipse 检查了一个项目,但出现以下错误:
- The project cannot be built until build path errors are resolved
- Unbound classpath container: 'JRE System Library[jdk1.5.0_08]'
- 在解决构建路径错误之前无法构建项目
- 未绑定的类路径容器:'JRE 系统库 [jdk1.5.0_08]'
I'm assuming the first error will be resolved as soon as the second one is. I think I need to install JDK 1.5.0_08 and set it as a jre system library for the project but I can't find anywhere to download it - the closest I can get is JDK 1.5.0_22.
我假设第一个错误将在第二个错误出现后立即解决。我想我需要安装 JDK 1.5.0_08 并将其设置为项目的 jre 系统库,但我找不到任何地方可以下载它 - 我能得到的最接近的是 JDK 1.5.0_22。
If anyone could provide an alternative solution (or a download link for jdk1.5.0_08 I suppose) I would appreciate it.
如果有人可以提供替代解决方案(或者我想是 jdk1.5.0_08 的下载链接),我将不胜感激。
采纳答案by andi5
Given the FAQ, sharing a project file seems have to have advantages and is even recommended practice for Java projects (personally, I would not do that).
鉴于FAQ,共享项目文件似乎具有优势,甚至是 Java 项目的推荐做法(就我个人而言,我不会这样做)。
Maybe some of the following work for you:
也许以下一些对你有用:
- Edit the project's properties (right-click project, Properties, Java Build Path, Libraries, Remove and Add Library.
- Import the project's files without the "project file"
- Install JDK1.5 from http://java.sun.com/javase/downloads/index_jdk5.jspand see whether you can fix paths
- 编辑项目的属性(右键单击项目、属性、Java 构建路径、库、删除和添加库。
- 导入没有“项目文件”的项目文件
- 从http://java.sun.com/javase/downloads/index_jdk5.jsp安装 JDK1.5看看是否可以修复路径
回答by Han
I had a similar problem when I recreated my workspace that was fixed in the following way:
当我重新创建以以下方式修复的工作区时,我遇到了类似的问题:
Go to Eclipse -> Preferences, under Java select "Installed JREs" and check one of the boxes to specify a default JRE. Click OK and then go back to your project's properties. Go to the "Java Build Path" section and choose the "Libraries" tab. Remove the unbound System Default library, then click the "Add Library" button. Select "JRE System Library" and you should be good to go!
转至 Eclipse -> Preferences,在 Java 下选择“Installed JREs”并选中其中一个框以指定默认 JRE。单击“确定”,然后返回到项目的属性。转到“Java Build Path”部分并选择“Libraries”选项卡。删除未绑定的系统默认库,然后单击“添加库”按钮。选择“JRE 系统库”,您就可以开始使用了!
回答by user3468976
To fix this:
要解决此问题:
- Right click your project –> Build Path –>Configure Build Path
- Select JRE Library and click Edit and from Edit library window choose alternate JRE whatever been configured with your eclipse then click Finish
- 右键单击您的项目-> 构建路径-> 配置构建路径
- 选择 JRE Library 并单击 Edit,然后从 Edit library 窗口中选择使用 eclipse 配置的备用 JRE,然后单击 Finish
回答by AppleGrew
This is pretty old question and I recently came across this. Also answers says make sure that you have the correct JDK registered in Installed JRE section of Eclipse properties, and that is it. I had the correct JDK registered and that was marked as default, but still I got this error. There is one more missing piece.
这是一个很老的问题,我最近遇到了这个问题。还回答说确保您在 Eclipse 属性的已安装 JRE 部分中注册了正确的 JDK,就是这样。我注册了正确的 JDK 并将其标记为默认值,但仍然出现此错误。还有一个缺失的部分。
Make sure the in the Installed JREs section the name of your target runtime environment is exactly as it is mentioned in your imported project. For example if the error you get is - Unbound classpath container: 'JRE System Library [JavaSE-1.8]'
. Then in Installed JREs you need to have JDK 1.8 registered and its name should be the exact value mentioned in square brackets, which in this case is JavaSE-1.8
.
确保在已安装的 JRE 部分中,目标运行时环境的名称与导入项目中提到的名称完全相同。例如,如果您得到的错误是 - Unbound classpath container: 'JRE System Library [JavaSE-1.8]'
。然后在已安装的 JRE 中,您需要注册 JDK 1.8,其名称应为方括号中提到的确切值,在本例中为JavaSE-1.8
.
回答by Hymanson
Indeed this problem is to be fixed under Preferences -> Java -> Installed JREs. If the desired JRE is apparent in the list - just select it, and that's it.
事实上,这个问题将在 Preferences -> Java -> Installed JREs 下修复。如果所需的 JRE 在列表中很明显 - 只需选择它,就可以了。
Otherwise it has to be installed on your computer first so you could add it with "Add" -> Standard VM -> Directory, in the pop-up browser window choose its path - something like "program files\Java\Jre#" -> "ok". And now you can select it from the list.
否则它必须首先安装在您的计算机上,以便您可以通过“添加”-> 标准虚拟机-> 目录添加它,在弹出的浏览器窗口中选择其路径 - 类似于“程序文件\Java\Jre#”- > “好的”。现在您可以从列表中选择它。
回答by Pardesi_Desi
- right clickon the project foldergo to Properties at bottom
- go to Java Build path
- clickon Libraries tab
- selectClasspath
- clickAdd Add Librarybutton on right
- selectJRE System Libraryand clickNextand then Finish
- clickApply and Closethe error should go away in IDE.
- 右键单击该项目文件夹中选择属性,在底部
- 转到Java 构建路径
- 点击上图书馆标签
- 选择类路径
- 单击右侧的添加添加库按钮
- 选择JRE 系统库,然后单击下一步,然后单击完成
- 单击应用并关闭错误应该在 IDE 中消失。
回答by Prakash Kaushal
The problem happens when you
问题发生在你
- Import project foldersinto the eclipse workspace.(when projects use different Jre).
- Updateor Reinstall eclipse
- ChangeJre or Build relatedSettings.
- Or by there is a configuration mismatch.
- 将项目文件夹导入 eclipse 工作区。(当项目使用不同的 Jre 时)。
- 更新或重新安装 eclipse
- 更改Jre 或 Build 相关设置。
- 或者配置不匹配。
You get two errors for each misconfigured files.
每个配置错误的文件都会出现两个错误。
- The project cannot be built until build path errors are resolved.
- Unbound classpath container: 'JRE System Library.
- 在解决构建路径错误之前,无法构建项目。
- 未绑定的类路径容器:'JRE 系统库。
If the no. of projects having problem is few:
如果没有。有问题的项目很少:
- Selecteachprojectand apply Quick fix(Ctrl+1)
- Either Replace the project's JRE with default JREor Specify Alternate JRE(or JDK).
You can do the same by right-click project-->Properties(from context menu)-->Java Build Path-->Libraries-->select current unbound library-->Remove-->Add Libraries-->Jre System library-->select default or alternateJre.
Or directly choose Build Path-->Add libraries in project's context menu.
- 选择每个项目并应用快速修复(Ctrl+1)
- 无论是使用默认JRE更换项目的JRE或指定替代JRE(或JDK)。
您可以通过右键单击项目--> 属性(从上下文菜单)--> Java 构建路径--> 库-->选择当前未绑定的库--> 删除--> 添加库--> Jre 系统来执行相同操作库-->选择默认或备用Jre。
或者直接在项目的上下文菜单中选择 Build Path-->Add libraries。
But the best way to get rid of such problem when you have many projects is:
但是,当您有很多项目时,摆脱此类问题的最佳方法是:
EITHER
任何一个
- Openthe current workspace(in which your project is) in File Explorer.
- Delete all org.eclipse.jdt.core.prefs file present in .settings folder of your imported projects.(Be careful while deleting.Don't delete any files or folders inside .metadata folder.)**
- Now,Select the .classpath files of projects(those with errors) and openthem in a powerful text editor(such as Notepad++).
- Find the line similar to
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
and replace it with<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- Saveall the files. And Refresh or restart Eclipse IDE.All the problems are gone.
- 在文件资源管理器中打开当前工作区(您的项目所在的工作区)。
- 删除导入项目的 .settings 文件夹中存在的所有 org.eclipse.jdt.core.prefs 文件。(删除时要小心。不要删除 .metadata 文件夹中的任何文件或文件夹。)**
- 现在,选择项目的 .classpath 文件(那些有错误的)并在强大的文本编辑器(如 Notepad++)中打开它们。
- 找到类似的行
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
并将其替换为<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- 保存所有文件。并刷新或重新启动 Eclipse IDE。所有的问题都没有了。
OR
或者
Get the JRE used by the projects and install on your computer and then specify it..
获取项目使用的JRE并安装在您的计算机上,然后指定它..
回答by user3627722
I had the same problem even after installing JDK 1.7. I corrected it by adding the bin directory to my PATH. So I went to
即使在安装 JDK 1.7 之后我也遇到了同样的问题。我通过将 bin 目录添加到我的 PATH 来纠正它。所以我去了
computer>properties>advanced>environment variables
计算机>属性>高级>环境变量
and then added
然后添加
C:\Program Files\Java\jdk1.7.0_55\bin;
C:\Program Files\Java\jdk1.7.0_55\bin;
then I followed these instructions
然后我按照这些说明
http://clean-clouds.com/2012/12/06/how-to-install-and-add-jre7-in-eclipse/
http://clean-clouds.com/2012/12/06/how-to-install-and-add-jre7-in-eclipse/
回答by Ebey Pradeep
Click on the error message displaying "Unbound classpath container: 'JRE System Library[jdk1.5.0_08]", left click anyd choose quick fix. Under quick, list of possible options will get displated. Choose replace library. Choose the library you installed. Your good to go.
单击显示“未绑定的类路径容器:'JRE 系统库[jdk1.5.0_08]”的错误消息,左键单击任意选择快速修复。在快速下,可能的选项列表将被删除。选择替换库。选择您安装的库。你好去。
回答by Harshil
I got the Similar issue while importing the project.
我在导入项目时遇到了类似的问题。
The issue is you select "Use an execution environment JRE" and which is lower then the libraries used in the projects being imported.
问题是您选择了“使用执行环境 JRE”,这低于正在导入的项目中使用的库。
There are two ways to resolve this issue:
有两种方法可以解决此问题:
1.While first time importing the project:
1.第一次导入项目时:
in JRE tab select "USE project specific JRE" instead of "Use an execution environment JRE".
2.Delete the Project from your work space and import again. This time:
2.从您的工作空间中删除项目并再次导入。这次:
select "Check out as a project in the workspace" instead of "Check out as a project configured using the new Project Wizard"