Eclipse: Java1.7(未绑定库)的挫折

我在一个全新的 Eclipse 安装中遇到了一个全新的项目的麻烦:

  1. 下载这个版本的 Eclipse: http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/heliosr

  2. 解压到 程序文件 eclipsejava

  3. 启动 Eclipse; 选择一个工作区

  4. 文件 > 新的 > Java 计划

  5. 项目名称: 你好,世界.JRE: “使用执行环境 JRE: JavaSE-1.7”

  6. 下一个,进入图书馆选项卡。唯一的入口是 JRE 系统库[ JavaSE-1.7](未绑定)。“未绑定”是什么意思?我该怎么补救?

  7. 结束

期望: 全新项目施工顺利。

实际: 有两个错误:

The project cannot be built until build path errors are resolved HelloWord  Unknown Java Problem
Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'HelloWord' HelloWord  Build path Build Path Problem

我做错了什么?

更新: 也许我的机器上实际上没有 Java7 JDK?

更新2: 看起来 Java7实际上还没有发布。

114807 次浏览

Have you actually downloaded and installed one of the milestone builds from https://jdk7.dev.java.net/ ?

You can have a play with the features, though it's not stable so you shouldn't be releasing software against them.

1) Find out where java is installed on your drive, open a cmd prompt, go to that location and run ".\java -version" to find out the exact version. Or, quite simply, check the add/remove module in the control panel.

2) After you actually install jdk 7, you need to tell Eclipse about it. Window -> Preferences -> Java -> Installed JREs.

Most of the time after the installation of Eclipse eclipse.ini is changed. If you change the jdk in eclipse.ini then eclipse will use this jdk by default.

Let's say you install a new version of Eclipse and you have forgotten to change the eclipse.ini related to the jdk. Then Eclipse finds a jdk for you. Let's say it is java 1.6 that was automatically discovered (you did nothing).

If you use maven (M2E) and you reference a 1.7 jdk then you will see the frustrating message. But normally it is not displayed because you configure the correct jdk in eclipse.ini.

That was my case. I made reference into the pom to a jdk that was not configured into Eclipse.

In the screenshot you can see that 1.7 is configured and seen by Eclipse. In this case, you should make reference into the pom to a jre that is compatible with 1.7! If not -> frustrating message!

jdk 1.7 configured in eclipse.ini and retrieved in installed jre

1)Go to configure build path . 2)Remove unbound JRE library . 3)Add library --> JRE System library .

Then project compile and done ..

To set JDK you can watch this video : how to set JDK . Then when you'll have JDK:

  1. Right click on build path and select "Build Path"
  2. Choose "Configure Build Path"
  3. Click on "JRE System Library [JavaSE-1.7] (unbound)"
  4. Edit it
  5. Choose "Alternate JRE"
  6. Click on "Installed JREs.." button
  7. Press Add
  8. Choose to add "Standard VM"
  9. Choose JRE Home directory - usually it is locates in "C:\Program Files\Java\jre7" directory
  10. Press "Finish"
  11. Re-check newly appeared "Jre7": Verify that now when you edit "JRE System Library [JavaSE-1.7]" "Alternate JRE" is chosen for jre7.

Cause : This is common scenario when we import new project with different lib and JAR path.

I faced this issue and got resolved using exact following steps:

  • Project > Properties
  • Build Path > Configure Build Path
  • Select "Libraries" tab
  • Click "Add Library"
  • Select "JRE System Library" from displayed list
  • Click on "Next" followed by "Finish" button

This will point your system's proper & valid JRE path, which did thing for me. Cheers :)

Updated eclipse.ini file with key value property -Dosgi.requiredJavaVersion=1.7 (or) 1.8 whichever applicable. - it works for me.

Updated eclipse.ini file with key-value property

-Dosgi.requiredJavaVersion=1.5

to

-Dosgi.requiredJavaVersion=1.8

because, that is my JAVA version.

Also, selected JRE 1.8 as my project library