Java Mac OS X 上 IntelliJ IDEA 中的 JDK 文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4145734/
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 documentation in IntelliJ IDEA on Mac OS X
提问by Chris Williams
I'd like to know how to setup IntelliJ to point to the JDK documentation so the documentation popups that display during code completion will show me what the function I'm looking at is going to do. For some reason IntelliJ isn't able to find the JavaDocs by default.
我想知道如何设置 IntelliJ 以指向 JDK 文档,以便在代码完成期间显示的文档弹出窗口将向我展示我正在查看的函数将要执行的操作。出于某种原因,IntelliJ 默认无法找到 JavaDocs。
I'm also not 100% sure that the documentation is installed with the JDK that's installed with the OS. I don't see them in /System/Library/Frameworks/JavaVM.framework/ but I may be looking in the wrong place. If it's not included, I'd also like to know what needs to be downloaded and where it needs to be installed to get the JavaDocs for the JDK to show up in IntelliJ.
我也不是 100% 确定文档是随操作系统安装的 JDK 一起安装的。我在 /System/Library/Frameworks/JavaVM.framework/ 中没有看到它们,但我可能找错了地方。如果不包括在内,我还想知道需要下载什么以及需要安装在哪里才能让 JDK 的 JavaDocs 显示在 IntelliJ 中。
采纳答案by Chris Williams
I had to combine the responses I got to this point and add a few extra details so I'm answering my own question.
我必须结合我目前得到的答复并添加一些额外的细节,以便我回答我自己的问题。
- Search for "Java developer" from Downloads for Apple Developers
- Download and install "Java for Mac OS X 10.6 Update 9 Developer Package" (or later).
- In IntelliJ, open File -> Project Structure.
- Click on "SDKs" under "Platform Settings".
Add the following paths under the "Documentation Paths" tab (the paths may be different based on which JDK you're using):
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/docs.jar!/docs/api /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/appledocs.jar!/appledoc/api
Add the following path under the Sourcepath tab:
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar!/src
- 从Apple Developers 下载中搜索“Java 开发人员”
- 下载并安装“Java for Mac OS X 10.6 Update 9 Developer Package”(或更高版本)。
- 在 IntelliJ 中,打开文件 -> 项目结构。
- 单击“平台设置”下的“SDK”。
在“文档路径”选项卡下添加以下路径(路径可能因您使用的 JDK 不同而不同):
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/docs.jar!/docs/api /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/appledocs.jar!/appledoc/api
在 Sourcepath 选项卡下添加以下路径:
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar!/src
Thanks, @Yishai for the download location and @Gareth Davis for the location of the documentation after installing.
谢谢,@Yishai 提供下载位置,@Gareth Davis 提供安装后文档的位置。
Update for 10.7/10.8 [Mountain] Lion:
10.7/10.8 [Mountain] Lion 更新:
Steps are the same except for these changes:
除以下更改外,步骤相同:
In step 2, download "Java for OS X 2012-005 Developer Package" (or later).
Use these paths instead in step 5.
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/docs.jar!/docs/api /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/appledocs.jar!/appledoc/api
Use these paths instead in step 7.
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/src.jar!/src
在第 2 步中,下载“Java for OS X 2012-005 Developer Package”(或更高版本)。
在步骤 5 中改用这些路径。
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/docs.jar!/docs/api /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/appledocs.jar!/appledoc/api
在步骤 7 中改用这些路径。
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/src.jar!/src
回答by Yishai
This should tell you what you need to know: Get local copies of Mac OS X Java source code and Javadoc – Concord Consortium wiki.
这应该会告诉您需要了解的内容:获取 Mac OS X Java 源代码和 Javadoc – Concord Consortium wiki 的本地副本。
That page recommends going to https://connect.apple.comand downloading and installing “Java for Mac OS X 10.5 Update 2 Developer Documentation (Disk Image)” or the equivalent newer release. It describes a few ways to view the documentation, based on the Java jar
file being located at a path like this:
该页面建议访问https://connect.apple.com并下载并安装“Java for Mac OS X 10.5 Update 2 开发人员文档(磁盘映像)”或等效的更新版本。它描述了几种查看文档的方法,基于jar
位于如下路径的 Java文件:
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/src.jar
回答by Gareth Davis
have you installed the Apple Java Developer package?
您是否安装了 Apple Java Developer 软件包?
It provides src.jar and docs.jar in /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home
它提供了 src.jar 和 docs.jar /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home
Note this is since update 3. If these are present Intellij will just find them, or at least mine did.
请注意,这是从更新 3 开始的。如果这些存在,Intellij 会找到它们,或者至少是我的。
details are in the Java update release notes
详细信息在Java 更新发行说明中
回答by Arne Evertsson
Quick (and dirty?) solution: Point IntelliJ to http://download.oracle.com/javase/6/docs/api/
快速(和肮脏?)解决方案:将 IntelliJ 指向http://download.oracle.com/javase/6/docs/api/