Java OSX 10.7 Lion 上的 JDK
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6614380/
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
JDK on OSX 10.7 Lion
提问by Wolf
I've instaled the Java for Developer package provided from Apple for 10.7 and java apps are running fine
我已经安装了 Apple 为 10.7 提供的 Java for Developer 包,并且 Java 应用程序运行良好
but eclipse cannot find the JDK root path and I cant either.
但是 eclipse 找不到 JDK 根路径,我也找不到。
Anybody any ideas?
有人有什么想法吗?
回答by Joerg Ruethschilling
On newer versions of OS X you should find ALL JREs (and JDKs) under
在较新版本的 OS X 上,您应该在下面找到所有 JRE(和 JDK)
/Library/Java/JavaVirtualMachines/
/库/Java/JavaVirtualMachines/
/System/Library/Java/JavaVirtualMachines/
/系统/库/Java/JavaVirtualMachines/
the old path
老路
/System/Library/Frameworks/JavaVM.framework/
/System/Library/Frameworks/JavaVM.framework/
has been deprecated.
已被弃用。
Here is the official deprecation note:
这是官方弃用说明:
回答by Yuri Brigance
I have just ran into the same problem after updating. The JRE that is downloaded by OSX Lion is missing JavaRuntimeSupport.jarwhich will work but can wreck havoc on a lot of things. If you've updated, and you had a working JDK/JRE installed prior to that, do the following in Eclipse:
更新后我刚刚遇到了同样的问题。OSX Lion 下载的 JRE 缺少JavaRuntimeSupport.jar,它可以工作,但可能会对很多事情造成严重破坏。如果您已经更新,并且在此之前安装了一个有效的 JDK/JRE,请在 Eclipse 中执行以下操作:
1) Project > Properties > Java Build Path > Select broken JRE/JDK > Edit
1)项目 > 属性 > Java 构建路径 > 选择损坏的 JRE/JDK > 编辑
2) Select "Alternate JRE"
2) 选择“备用 JRE”
3) Click "Installed JREs..."
3) 单击“已安装的 JRE...”
4) In the window that opens, click "Search..."
4) 在打开的窗口中,单击“搜索...”
If all goes well, it will find your older JRE/JDK. Mine was in this location:
如果一切顺利,它将找到您的旧 JRE/JDK。我在这个位置:
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
回答by Heath Borders
You can download the 10.7 Lion JDK from http://connect.apple.com.
您可以从http://connect.apple.com下载 10.7 Lion JDK 。
Sign in and click the
java
section on the right.The jdk is installed into a different location then previous. This will result in IDEs (such as Eclipse) being unable to locate source code and javadocs.
At the time of writing the JDK ended up here:
/Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home
Open up eclipse preferences and go to Java --> Installed JREspage
Rather than use the "JVM Contents (MacOS X Default) we will need to use the JDK location
At the time of writing Searchis not aware of the new JDK location; we we will need to click on the Addbutton
From the Add JREwizard choose "MacOS X VM" for the JRE Type
For the JRE Definition Pagewe need to fill in the following:
- JRE Home: /Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home
The other fields will now auto fill, with the default JRE name being "Home". You can quickly correct this to something more meaningful:
- JRE name: System JDK
Finish the wizard and return to the Installed JREspage
Choose "System JDK" from the list
You can now develop normally with:
- javadocs correctly shown for base classes
- source code correctly shown when debugging
登录并单击
java
右侧的部分。jdk 安装到与以前不同的位置。这将导致 IDE(例如 Eclipse)无法定位源代码和 javadoc。
在撰写本文时,JDK 最终出现在这里:
/库/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home
打开 eclipse 首选项并转到Java --> Installed JREs页面
我们需要使用 JDK 位置,而不是使用“JVM 内容(MacOS X 默认)”
在撰写本文时,Search不知道新的 JDK 位置;我们需要点击添加按钮
从添加 JRE向导中,为 JRE 类型选择“MacOS X VM”
对于JRE 定义页面,我们需要填写以下内容:
- JRE 主页:/Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home
其他字段现在将自动填充,默认 JRE 名称为“Home”。您可以快速将其更正为更有意义的内容:
- JRE 名称:系统 JDK
完成向导并返回到已安装的 JRE页面
从列表中选择“系统 JDK”
您现在可以正常开发:
- 正确显示基类的 javadocs
- 调试时正确显示源代码
回答by Martin Haeberli
For Mountain Lion, Apple's java is up to 1.6.0_35-b10-428.jdk as of today.
It is indeed located under /Library/Java/JavaVirtualMachines .
You just download
"Java for OS X 2012-005 Developer Package" (Sept 6, 2012)
from
http://connect.apple.com/
In my view, Apple's naming is at least a bit confusing; why "-005" - is this the fifth version, or the fifth of five installers one needs?
And then run the installer; then follow the above steps inside Eclipse.
对于 Mountain Lion,截至今天,Apple 的 java 最高为 1.6.0_35-b10-428.jdk。
它确实位于 /Library/Java/JavaVirtualMachines 下。
您只需
从http://connect.apple.com/下载
“Java for OS X 2012-005 Developer Package”(2012 年 9 月 6 日)
在我看来,Apple 的命名至少有点混乱;为什么“-005” - 这是第五个版本,还是需要的五个安装程序中的第五个?
然后运行安装程序;然后在 Eclipse 中按照上述步骤操作。
回答by RxRead
You can download jdk6 here http://support.apple.com/kb/DL1573
你可以在这里下载 jdk6 http://support.apple.com/kb/DL1573
Wish it helps
希望有帮助