如何在 Eclipse 中查看 Javadoc?

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

How to view Javadoc in Eclipse?

javaeclipsejavadoc

提问by James Raitsev

I am using a third party library, i have included into my project. It contains classes for the application, but no sources, or Javadoc. As expected, mouse-over imported object shows no javadoc.

我正在使用第三方库,我已包含在我的项目中。它包含应用程序的类,但没有源代码或 Javadoc。正如预期的那样,鼠标悬停在导入的对象上不显示 javadoc。

Note: This element neither has attached source nor attached 
Javadoc and hence no Javadoc could be found.

After googling for a bit, i came across 3 versions of jars

在谷歌搜索了一下之后,我遇到了 3 个版本的 jars

  1. app.jar
  2. app-sources.jar
  3. app-javadoc.jar
  1. 应用程序.jar
  2. app-sources.jar
  3. 应用程序-javadoc.jar

It appears and app-javadoc.jar contains nothing but html pages and app-sources contans nothing but .java files (with Javadoc comments).

它出现并且 app-javadoc.jar 只包含 html 页面,而 app-sources 只包含 .java 文件(带有 Javadoc 注释)。

What i did:

我做了什么:

  • Added all 3 files to the list of "Referenced Libraries". After "refresh"ing the project, javadoc still does not show.

  • Additionally, under properties for the project, i pointed "Javadoc location path" to unzipped content of app-javadoc.jar (validated ok)

  • 将所有 3 个文件添加到“参考库”列表中。“刷新”项目后,javadoc 仍然没有显示。

  • 此外,在项目的属性下,我将“Javadoc 位置路径”指向 app-javadoc.jar 的解压缩内容(验证正常)

Still, after having done all that, my Eclipse fails to display javadoc.

尽管如此,在完成所有这些之后,我的 Eclipse 无法显示 javadoc。

Please advise

请指教

Thank you.

谢谢你。

采纳答案by Rahul

Add only app.jar to the Referenced Libraries.

仅将 app.jar 添加到引用的库中。

then, go to Project Explorer, right click on the jar file-> Properties -> Javadoc Location and add Javadoc jar location (app-javadoc.jar).

然后,转到项目资源管理器,右键单击 jar 文件 -> 属性 -> Javadoc 位置并添加 Javadoc jar 位置(app-javadoc.jar)。

If you want to also browse the source code, then go to 'Java Source attachment' in the same dialog box and add the app-sources.jar there.

如果您还想浏览源代码,请转到同一对话框中的“Java 源附件”并在其中添加 app-sources.jar。

回答by YODA

I think you should set the javadoc location to the library itself but not the Project's javadoc location property.

我认为您应该将 javadoc 位置设置为库本身,而不是项目的 javadoc 位置属性。

Project > Properties > Java Build Path > Libraries expand the app.jar node and select the "Javadoc location" sub node and you can see the "Edit" button at the right of the library tree is enabled. Then click the "Edit" button and you can choose your javadoc in a jar file.

Project > Properties > Java Build Path > Libraries 展开 app.jar 节点并选择“Javadoc location”子节点,可以看到库树右侧的“Edit”按钮被启用。然后单击“编辑”按钮,您可以在 jar 文件中选择您的 javadoc。

I am using Eclipse not MyEclipse but I think they are similiar. FYI

我使用的是 Eclipse 而不是 MyEclipse,但我认为它们很相似。供参考

回答by Argent

Here is an answer as of 2016-05-12:

这是截至 2016-05-12 的答案:

In the Eclipse Project Explorer, under Referenced Libraries, right click on the jar file for which you require documentation. In the present example I require documentation for the Apache Commons IO library.

在 Eclipse Project Explorer 中,在 Referenced Libraries 下,右键单击您需要文档的 jar 文件。在本示例中,我需要 Apache Commons IO 库的文档。

enter image description here

在此处输入图片说明

Select Properties. Then select Javadoc Location:

选择属性。然后选择 Javadoc 位置:

enter image description here

在此处输入图片说明

In the case that I am considering--the Apache Commons IO library--the javadoc jar file is stored in the same directory as the library jar file. In the Properties dialog, select Javadoc in Archive, navigate to the relevant directory, and click on the javadoc jar file:

在我考虑的情况下——Apache Commons IO 库——javadoc jar 文件与库 jar 文件存储在同一目录中。在 Properties 对话框中,在 Archive 中选择 Javadoc,导航到相关目录,然后单击 javadoc jar 文件:

enter image description here

在此处输入图片说明

Click Open, click OK, and you're done. As shown below, when you hover your cursor over an Apache Commons IO class name the javadoc appears:

单击“打开”,单击“确定”,您就完成了。如下所示,当您将光标悬停在 Apache Commons IO 类名称上时,会出现 javadoc:

enter image description here

在此处输入图片说明