Mac OS X Java 更新的源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4120107/
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-14 11:48:49  来源:igfitidea点击:

Source code for Mac OS X Java Updates

javamacos

提问by curthipster

Java for Mac OS X 10.6 Update 3 upgraded to java 1.6.0_22. However, they did not include the source code or JavaDoc. Does anyone know if Apple provides the source, and if so, where to find it?

Java for Mac OS X 10.6 Update 3 升级到 java 1.6.0_22。但是,它们不包括源代码或 JavaDoc。有谁知道Apple是否提供了来源,如果有,在哪里可以找到?

I'd like to attach the source to Eclipse.

我想将源代码附加到 Eclipse。

采纳答案by Chris Lercher

I had the same problem today - I installed the Java Developer package from http://connect.apple.com, but couldn't find "src.jar" in /System/Library/Frameworks/JavaVM.framework/...anymore. On my machine, it's now in
/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar.

我今天遇到了同样的问题 - 我从http://connect.apple.com安装了 Java Developer 包,但再也找不到“src.jar”/System/Library/Frameworks/JavaVM.framework/...了。在我的机器上,它现在在
/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar.

Update:For the latest version from March 2011, the jar is now:
/Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar

更新:对于 2011 年 3 月的最新版本,jar 现在是:
/Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar

Once again, you'll have to download the new Java Developer package first.

同样,您必须先下载新的 Java Developer 包。

回答by lindon fox

I found that the solutions were not working for me (not sure what I am doing wrong), but I was able to see the source in Eclipse when I selected the directory of src.jarinstead of specifying the actual jar.

我发现这些解决方案对我不起作用(不确定我做错了什么),但是当我选择目录src.jar而不是指定实际 jar时,我能够在 Eclipse 中看到源代码。

回答by oae

Found it also not working after download and installation. Using the directory didn't work either for me. This helped finally:

下载安装后发现也无法使用。使用该目录对我也不起作用。这最终帮助:

 sudo cp  /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/

and the linked it through eclipse!

并通过eclipse链接它!

回答by Steve Powell

What I do is as follows:

我的做法如下:

Download and install the Java Developer Kit (using your developer AppleId), current version 1.6.0_24-b07-334.jdk, and then in a shell, cd to the /System/Library/Frameworks/JavaVM.framework/Homedirectory.

下载并安装 Java 开发工具包(使用您的开发人员 AppleId),当前版本1.6.0_24-b07-334.jdk,然后在 shell 中,cd 到该/System/Library/Frameworks/JavaVM.framework/Home目录。

Put in symbolic links to the jdk source files, src.jar, docs.jarand appledocs.jar, in the jdk you've just downloaded, that is:

在刚刚下载的 jdk 中src.jar,放入指向 jdk 源文件 、docs.jar和 的符号链接appledocs.jar,即:

sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar src.jar

sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar src.jar

and similarly for the other two jars.

其他两个罐子也是如此。

Then, in Eclipse/Preferences, you can create a new Installed JREby duplicatingthe existing one (the existing one points to something like /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home) and then select the new Installed JREand remove the original.

然后,在Eclipse/Preferences 中,您可以通过复制现有的JRE(现有的指向类似)来创建一个新的Installed JRE,然后选择新的Installed JRE并删除原始的。/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

The Eclipse Projects might need updating to point to the 'new' JRE, but the source and javadocs should now be available for the standard java stuff without further ado.

Eclipse 项目可能需要更新以指向“新”JRE,但源代码和 javadoc 现在应该可以用于标准 java 内容,不用多说。

NBEnsure that the version of the jdk matches the version of your system Java for this to work properly.

注意确保 jdk 的版本与您的系统 Java 版本相匹配,以使其正常工作。

回答by Bohemian

These are the exact steps that worked for me.

这些是对我有用的确切步骤。

Go to the apple dev java downloads pageand get the latest one you can (the apple dev web site will not let you download packages that are unsuitable for your OS version).
I installed Java Developer Package for Mac OS X 10.6 Update 5 (Disk Image).

转到apple dev java 下载页面并获取最新的下载(apple dev 网站不会让您下载不适合您的操作系统版本的软件包)。
为 Mac OS X 10.6 Update 5 (Disk Image)安装了Java Developer Package

Then I executed these commands:

然后我执行了这些命令:

sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-384.jdk/Contents/Home/src.jar /System/Library/Frameworks/JavaVM.framework/Home/src.jar
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-384.jdk/Contents/Home/docs.jar /System/Library/Frameworks/JavaVM.framework/Home/docs.jar
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-384.jdk/Contents/Home/appledocs.jar /System/Library/Frameworks/JavaVM.framework/Home/appledocs.jar

Then I restarted Eclipse (I didn't have to create a new JRE).

然后我重新启动了 Eclipse(我不必创建新的 JRE)。

回答by carl

FYI; On a Macbook Pro 2008, however reinstalled from scratch with Lion and NetBeans 7.0.1, thus the package Java 10.7 update 1 (the latest release), the source and JavaDoc were luckily auto installed after downloading the developer package as described in this thread. All is well.

供参考; 在 Macbook Pro 2008 上,但是使用 Lion 和 NetBeans 7.0.1 从头重新安装,因此包 Java 10.7 update 1(最新版本),幸运的是,在下载开发人员包后自动安装了源代码和 JavaDoc,如本线程所述。一切都很好。

回答by jadc

On 31-Jan-2012, Apple posted the Java for Mac OS X Developer Preview 11M3614+10M3614on their developer site.

2012 年 1 月 31 日,Apple在其开发者网站上发布了Java for Mac OS X Developer Preview 11M3614+10M3614

This is a version that includes source code, doc, etc. (i.e., everything a developer needs).

这是一个包含源代码、文档等(即开发人员需要的一切)的版本。

回答by pm_labs

For OSX 10.7 Lion running Java update 1, I found the sources to be in: /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar. As noted in the other answers, you will first need to download and install the Java Developer package from Apple before setting this directory in your IDE.

对于运行 Java 更新 1 的 OSX 10.7 Lion,我发现源位于:/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar。正如其他答案中所述,在您的 IDE 中设置此目录之前,您首先需要从 Apple 下载并安装 Java Developer 包。

回答by Alexander Fedorov

Install java source, docs in 8 steps:

安装java源码、文档8步:

  1. Sign in with your Apple ID(http://connect.apple.com)

  2. Go to https://developer.apple.com/downloads/index.action

  3. Download Java for OS X 2012-00* Developer Package

  4. Install javadeveloper_for_os_x_ * .dmg.

  5. Go to Eclipse > Preferences > Java > Installed JRE

  6. Click Search...

  7. Choose JRE with location like /Library/Java/JavaVirtualMachines/1.6.0_your_jdk_filename.jdk/contents/home. In my case jdk file name was 1.6.0_33-b03-424.jdk.

    You can find the file name of jdk in terminal: ls -l /Library/Java/JavaVirtualMachines

  8. Now, when you try "open declaration" and get message "Source Not Found" press button Attach source...and paste /Library/Java/JavaVirtualMachines/1.6.0_your_jdk_filename.jdk/contents/home/src.jar

  1. 使用您的 Apple ID 登录( http://connect.apple.com)

  2. 转到https://developer.apple.com/downloads/index.action

  3. 下载Java for OS X 2012-00* 开发包

  4. 安装javadeveloper_for_os_x_ * .dmg

  5. 转到Eclipse > 首选项 > Java > 已安装的 JRE

  6. 点击搜索...

  7. 选择位置类似于/Library/Java/JavaVirtualMachines/ 1.6.0_your_jdk_filename.jdk/contents/home 的JRE 。在我的情况下,jdk 文件名是1.6.0_33-b03-424.jdk.

    您可以在终端中找到 jdk 的文件名: ls -l /Library/Java/JavaVirtualMachines

  8. 现在,当您尝试“打开声明”并收到消息“未找到源”时,请按按钮附加源...并粘贴 /Library/Java/JavaVirtualMachines/ 1.6.0_your_jdk_filename.jdk/contents/home/src.jar