如何在IntelliJ IDEA中查看JDK外部文档?

发布于 2024-12-22 09:51:46 字数 264 浏览 1 评论 0原文

此操作的快捷方式是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

风尘浪孓 2024-12-29 09:51:46

您需要指定解压文档的 docs/api 子目录或使用 https://docs.oracle.com/javase/8/docs/api/ 的 URL 作为外部文档功能正常工作。

文件 ->项目结构... 然后在这里:
输入图像描述这里

You need to specify the docs/api subdirectory of the unpacked documentation or use https://docs.oracle.com/javase/8/docs/api/ URL for the external documentation feature to work.

File -> Project Structure... then here :
enter image description here

長街聽風 2024-12-29 09:51:46

我正在使用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.

末骤雨初歇 2024-12-29 09:51:46

您可以添加外部 Javadocs API 链接,如下所示:

在此处输入图像描述

You can add the external Javadocs API link as shown below:

enter image description here

謸气贵蔟 2024-12-29 09:51:46

对于 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

2024-12-29 09:51:46

在此发布此内容是为了防止您像我一样不一定需要 javadoc,而是需要 IDE 中的文档。

在我的情况下,我已经下载了 OpenJDK 11,但无法获取 IntelliJ 内的文档。相反,我得到的是反编译的代码。

对我有帮助的是 https://stackoverflow.com/a/38413439 的答案

  1. 转到文件>项目结构> SDK>源路径>右侧的“+”。
  2. 导航到您的 JDK(我使用的是 Ubuntu,因此它位于 /usr/lib/jvm/openjdk-11/ 下)。
  3. 选择src.zip(对我来说,/usr/lib/jvm/openjdk-11/lib/src.zip)。
  4. 点击确定>确定(到“选择根”弹出窗口)> OK(到项目结构)

让 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.

  1. Go to File > Project Structure > SDKs > Sourcepath > '+' on the right side.
  2. Navigate to your JDK (I'm on Ubuntu so it was located under /usr/lib/jvm/openjdk-11/).
  3. Select the src.zip (for me, /usr/lib/jvm/openjdk-11/lib/src.zip).
  4. Click OK > OK (to "Choose Roots" pop-up) > OK (to Project Structure)

Let Intellij index and it should be available in your IDE.

马蹄踏│碎落叶 2024-12-29 09:51:46

我对这个问题的理解如下:

您希望查看不在 JDK 内的类的 javadoc。我有点不确定,因为 CrazyCoder 的回复正在谈论 JDK 特定的 javadocs。

I am using Macos 10.8.4 and Intellij 11.1.5

我正在从事的项目是一个基于 mvn 的项目,其中包含许多具有复杂依赖关系的模块。

让我举一个具体的例子来解释我所做的,我相信它可以为其他人复制: apa​​che sshd

我从mavencentral 下载了javadoc,并将其存储在某处。在 intellij 中,我进入了模块设置(快捷键 F4)和侧边栏中的库。 Maven 自动提取所有依赖项,我可以在那里找到 sshd。右侧显示类、源代码和 JavaDocs。在我的例子中,JavaDocs 部分有一个链接的路径,指向我的本地 m2 目录。但是该目录不包含 javadoc jar 文件。所以我想如何获得它:

mvn dependency:resolve -Dclassifier=javadoc

取自此处

但是,这失败了,因为我们的关系中没有一些 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.

I am using Macos 10.8.4 and Intellij 11.1.5

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:

mvn dependency:resolve -Dclassifier=javadoc

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.

夜访吸血鬼 2024-12-29 09:51:46

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/

乱了心跳 2024-12-29 09:51:46

其他答案令人满意,但如果您仍然看不到文档,请确保您的 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.

北凤男飞 2024-12-29 09:51:46

添加在线 URL 作为文档会导致文档弹出延迟。我更喜欢从本地链接我的资源以实现零延迟。

您应该能够在 jdk/lib/src.zip 路径中找到 src.zip。将该存档添加到您的文档路径中,然后就一切就绪了。

如果使用其他 JDK,您可以单独获取源代码。或者可能会捆绑在一起。

Intellij JDK javadocs 设置

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 in jdk/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.

Intellij JDK javadocs setup

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文