如何在IntelliJ IDEA中查看JDK外部文档?
此操作的快捷方式是 Shift+F1,但它始终呈灰色显示,即使我已将 JDK 文档路径
指向 docs
文件夹(docs 文件夹是从 jdk-7u2-apidocs.zip )。
谢谢
The shortcut for this action is Shift+F1 but it is always grayed out even though I have pointed JDK documentation path
to the docs
folder (the docs folder is unzipped from jdk-7u2-apidocs.zip ).
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您需要指定解压文档的 docs/api 子目录或使用 https://docs.oracle.com/javase/8/docs/api/ 的 URL 作为外部文档功能正常工作。
文件 ->项目结构...
然后在这里:You need to specify the
docs/api
subdirectory of the unpacked documentation or usehttps://docs.oracle.com/javase/8/docs/api/
URL for the external documentation feature to work.File -> Project Structure...
then here :我正在使用10.5.4。从文档或在线资源中,我不清楚您是否需要将其添加到“项目结构”>“项目结构”中。 SDK的> (选择您的SDK)>文档路径>指定网址。
I'm using 10.5.4. It was unclear to me from the docs or from resources online that you need to add this at Project Structure > SDK's > (Choose your SDK) > Documentation Paths > Specify URL.
您可以添加外部 Javadocs API 链接,如下所示:
File
>项目结构...
SDKs
(在平台设置
下)文档路径
选项卡指定 URL
按钮并添加 JDK 11 API 文档的链接 (https://docs.oracle.com/en/java/javase/11/docs/api/)You can add the external Javadocs API link as shown below:
File
>Project Structure...
SDKs
(underPlatform Settings
)Documentation Paths
tabSpecify URL
button and add the link for JDK 11 API docs (https://docs.oracle.com/en/java/javase/11/docs/api/)对于 IntelliJ Idea:
调用“项目结构”(Ctrl+Shift+Alt+S),进入“平台设置 - SDKs”,选择右侧的“文档路径”选项卡,然后添加 JavaDoc 的 url (http://docs.oracle.com/javase/7/docs/api/) 到您的项目
For IntelliJ Idea:
Call "Project Structure" (Ctrl+Shift+Alt+S), go to "Platform Setting - SDKs", choose "Documentation Path" tab on the right, then add url of JavaDoc (http://docs.oracle.com/javase/7/docs/api/) to your project
在此发布此内容是为了防止您像我一样不一定需要 javadoc,而是需要 IDE 中的文档。
在我的情况下,我已经下载了 OpenJDK 11,但无法获取 IntelliJ 内的文档。相反,我得到的是反编译的代码。
对我有帮助的是 https://stackoverflow.com/a/38413439 的答案
即
/usr/lib/jvm/openjdk-11/
下)。src.zip
(对我来说,/usr/lib/jvm/openjdk-11/lib/src.zip
)。让 Intellij 建立索引,它应该在您的 IDE 中可用。
Posting this here in case you're like me and don't necessarily want javadocs, but rather the documentation inside your IDE.
In my situation, I had downloaded OpenJDK 11 and wasn't able to get documentation inside IntelliJ. Instead I was getting decompiled code.
What helped me was the answer at https://stackoverflow.com/a/38413439
i.e.
/usr/lib/jvm/openjdk-11/
).src.zip
(for me,/usr/lib/jvm/openjdk-11/lib/src.zip
).Let Intellij index and it should be available in your IDE.
我对这个问题的理解如下:
您希望查看不在 JDK 内的类的 javadoc。我有点不确定,因为 CrazyCoder 的回复正在谈论 JDK 特定的 javadocs。
我正在从事的项目是一个基于 mvn 的项目,其中包含许多具有复杂依赖关系的模块。
让我举一个具体的例子来解释我所做的,我相信它可以为其他人复制: apache sshd
我从mavencentral 下载了javadoc,并将其存储在某处。在 intellij 中,我进入了模块设置(快捷键 F4)和侧边栏中的库。 Maven 自动提取所有依赖项,我可以在那里找到 sshd。右侧显示类、源代码和 JavaDocs。在我的例子中,JavaDocs 部分有一个链接的路径,指向我的本地 m2 目录。但是该目录不包含 javadoc jar 文件。所以我想如何获得它:
取自此处
但是,这失败了,因为我们的关系中没有一些 javadoc(我猜,不确定)。
因此,我最终将手动下载的文件链接为 javadoc 链接,然后我可以使用 Shift+F1 在标准浏览器中打开 javadoc。
也许其他人可以详细说明如何使用 mvn 完成此操作。我没有时间进一步调查。
I understand the question as follows:
You would like to see javadocs of classes that are not within JDK. I am a bit uncertain because CrazyCoder's reply is talking about JDK specific javadocs.
The project I am working on is a mvn based project with many modules which have complex dependencies.
Let me take a concrete example to explain what I did, I am sure it can be reproduced for others: apache sshd
I downloaded the javadoc from maven central stored it stored it somewhere. In intellij I went to the module settings (shortcut F4) and the to Libraries in the sidebar. Maven pulls all dependencies automagically and I can find sshd there. The right side then shows Classes, Sources and JavaDocs. The JavaDocs part in my case had a path linked in that pointed to my local m2 directory. However the directory did not contain the javadoc jar file. So I thought how do I get it:
Taken from here
However this failed for because we do not have some javadocs in our nexus (I guess, not sure).
So I ended up linking the file that I downloaded manually in as a javadoc link and this then allown me to use Shift+F1 for the javadoc to open in my standard browser.
Maybe others can elaborate on how to get this done with mvn. I did not have the time to further investigate.
Java 10 文档路径
转到文件 ->项目结构 选择下面的外部 URL
链接工作正常...默认的链接不起作用
https://docs.oracle.com/javase/10/docs/api/
Java 10 Documentation path
Got to File -> Project Structure Choose External URL
Below Link works Fine... THe default one does'nt work
https://docs.oracle.com/javase/10/docs/api/
其他答案令人满意,但如果您仍然看不到文档,请确保您的 java 文件位于 src 路径下。
Other answers are satisfying but in case you still can't see the documentation, make sure that your java file is located under the
src
path.添加在线 URL 作为文档会导致文档弹出延迟。我更喜欢从本地链接我的资源以实现零延迟。
您应该能够在
jdk/lib/src.zip
路径中找到src.zip
。将该存档添加到您的文档路径中,然后就一切就绪了。如果使用其他 JDK,您可以单独获取源代码。或者可能会捆绑在一起。
Adding online URL as documentation introduces a delay for the documentation to pop up. I prefer linking my sources from local for zero lag.
You should be able to find the
src.zip
injdk/lib/src.zip
path. Add that archive in your documentation paths and you're all set.If using some other JDK, you could grab the sources separately. Or might come bundled.