[英]How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
Presently I'm working with JavaFX.目前我正在使用 JavaFX。 Whenever I hover over a method of JavaFX its gives me the following error:
每当我将鼠标悬停在 JavaFX 的方法上时,它都会给我以下错误:
'Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found'
How should I resolve this?我应该如何解决这个问题? How can I attach the javadoc or source so that I could see the description of the methods?
如何附加 javadoc 或源代码以便我可以看到方法的描述?
You can configure the Javadocs with downloading jar, basically javadocs will be referred directly from internet.您可以通过下载 jar 来配置 Javadocs,基本上 javadocs 将直接从互联网上引用。
Complete steps:完成步骤:
for offline javadocs, you can download from : http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html对于离线 javadoc,您可以从以下位置下载: http : //www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html
After clicking Accept License Agreement you can download javafx-2_2_0-apidocs.zip单击接受许可协议后,您可以下载javafx-2_2_0-apidocs.zip
Neither Project/Properties/Javadoc Location nor Project/Properties/Java Build Path/Libraries had not helped me until I picked and moved up in " Order and Export " tab of " Java Build Path " "Android Dependencies" and added-in-library.jar. Project/Properties/Javadoc Location和Project/Properties/Java Build Path/Libraries都没有帮助我,直到我在“ Java Build Path ”“Android Dependencies”的“ Order and Export ”选项卡中移动并添加到库中。罐。 I hope it will be useful.
我希望它会很有用。
Alternatively you can also,或者你也可以,
1) Navigate to that method by Ctrl+Click on the method. 1) 通过 Ctrl+单击方法导航到该方法。 The new tab/window will opened with text "Source not found" and button "Attach Source.." in it
新选项卡/窗口将打开,其中包含文本“未找到源”和按钮“附加源..”
2) Click the button "Attach Source.." 2) 单击“附加源..”按钮
3) New window pops up. 3) 弹出新窗口。 Click the button "External Folder"
单击“外部文件夹”按钮
4) Locate the JavaFX javadoc folder. 4) 找到 JavaFX javadoc 文件夹。 If you are on Windows with default installation settings, then the folder path is
C:\\Program Files\\Oracle\\JavaFX 2.0 SDK\\docs
如果您在 Windows 上使用默认安装设置,则文件夹路径为
C:\\Program Files\\Oracle\\JavaFX 2.0 SDK\\docs
First, if you get the message首先,如果您收到消息
Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found
注意:此元素既没有附加源也没有附加 Javadoc,因此找不到 Javadoc
Then it means that you've already included the external jar needed for your project.那么这意味着您已经包含了项目所需的外部 jar。
The next step would be to associate the external jar with its javadoc url.下一步是将外部 jar 与其 javadoc url 相关联。
And you're all set!你已经准备好了!
Above all answers are right but there is another method also which is very handy.最重要的是答案是正确的,但还有另一种方法也非常方便。
Pre-condition: Your project is Maven project Or converts it to Maven project.前置条件:你的项目是Maven项目或者转换为Maven项目。
RightclickOnProject > Configuration > Convert in to Maven Project RightclickOnProject > 配置 > 转换为 Maven 项目
- Now follow the steps:
- 现在按照以下步骤操作:
1 . 1 . Select any jar for which you want to download sources or javadocs.
选择要为其下载源代码或 javadoc 的任何 jar。
2 . 2 . RightClick > Maven > Download javadoc or Download javasources
右键单击 > Maven > 下载 javadoc 或下载 javasources
I couldn't get the "Attach source..." method to work either, and I tried many different ways.我也无法使用“附加源...”方法,我尝试了许多不同的方法。 The Javadocs for JavaFX are installed in Program Files\\Oracle\\JavaFX 2.x SDK\\docs.
JavaFX 的 Javadocs 安装在 Program Files\\Oracle\\JavaFX 2.x SDK\\docs 中。 Another way to install the Javadocs is:
安装 Javadocs 的另一种方法是:
Hope this helps some people who were as puzzled as I was.希望这能帮助一些和我一样困惑的人。
In addition to the answer of @dhroove (would have written a comment if I had 50 rep...)除了@dhroove 的回答(如果我有 50 个代表,我会写评论......)
The link has changed to: http://docs.oracle.com/javafx/2/api/链接已更改为: http : //docs.oracle.com/javafx/2/api/
At least my eclipse wasn't able to use the link from him.至少我的日食无法使用他的链接。
It already in a different thread, just a simple eclipse setting will automatically download JavaDoc (but, you need to click the method for first time).它已经在一个不同的线程中,只需一个简单的 eclipse 设置就会自动下载 JavaDoc(但是,您需要第一次单击该方法)。
Where can I download the JavaDoc for JPA 2.0? 在哪里可以下载 JPA 2.0 的 JavaDoc?
This trick worked for me in Eclipse Luna (4.4.2): For a jar file I am using (htsjdk), I packed the source in a separate jar file (named htsjdk-2.0.1-src.jar; I could do this since htsjdk is open source) and stored it in the lib-src folder of my project.这个技巧在 Eclipse Luna (4.4.2) 中对我有用:对于我使用的 jar 文件 (htsjdk),我将源代码打包在一个单独的 jar 文件中(名为 htsjdk-2.0.1-src.jar;我可以这样做因为 htsjdk 是开源的)并将其存储在我的项目的 lib-src 文件夹中。 In my own Java source I selected an element I was using from the jar and hit F3 (Open declaration).
在我自己的 Java 源代码中,我从 jar 中选择了一个我正在使用的元素,然后按 F3(打开声明)。 Eclipse opened the class file and showed the button "Attach source".
Eclipse 打开类文件并显示“附加源”按钮。 I clicked the button and pointed to the src jar file I had just put into the lib-src folder.
我单击按钮并指向我刚刚放入 lib-src 文件夹中的 src jar 文件。 Now I get the Javadoc when hovering over anything I'm using from the jar.
现在,将鼠标悬停在 jar 中使用的任何内容上时,我会得到 Javadoc。
如果您使用的是 maven,请执行以下操作:
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
You could specify the online Javadoc location for a particular JAR in Eclipse.您可以为 Eclipse 中的特定 JAR 指定在线 Javadoc 位置。 This saved my day when I wasn't able to find any downloadable Javadocs for Kafka.
当我无法为 Kafka 找到任何可下载的 Javadoc 时,这挽救了我的一天。
Package Explorer
, right click on the intended JAR (under the project's Referenced Libraries or Maven Dependences or anything as such) and click on Properties
.Package Explorer
,右键单击预期的 JAR(在项目的 Referenced Libraries 或 Maven Dependences 或任何类似内容下),然后单击Properties
。Javadoc Location
.Javadoc Location
。Javadoc location path
field under Javadoc URL, enter the URL of the online Javadocs, which most likely ends with /<version>/javadoc/
.Javadoc location path
字段中,输入在线 Javadoc 的 URL,该 URL 很可能以/<version>/javadoc/
结尾。 For example, Kafka 2.3.0's Javadocs are located at http://www.apache.org/dist/kafka/2.3.0/javadoc/ (you might want to change https
to http
in your URL, as it raised an invalid location warning after clicking on Validate...
for me).https
更改为http
,因为它提出了一个无效的位置单击“ Validate...
对我而言”后发出警告)。To attach the Java source code with Eclipse,要使用 Eclipse 附加 Java 源代码,
When you install the JDK, you must have selected the option to install the Java source files too.安装 JDK 时,您也必须选择安装 Java 源文件的选项。 This will copy the src.zip file in the installation directory.
这将复制安装目录中的 src.zip 文件。 In Eclipse, go to Window -> Preferences -> Java -> Installed JREs -> Add and choose the JDK you have in your system.
在 Eclipse 中,转到 Window -> Preferences -> Java -> Installed JREs -> Add 并选择您系统中的 JDK。 Eclipse will now list the JARs found in the dialog box.
Eclipse 现在将列出在对话框中找到的 JAR。 There, select the rt.jar and choose Source Attachment.
在那里,选择 rt.jar 并选择 Source Attachment。 By default, this will be pointing to the correct src.zip.
默认情况下,这将指向正确的 src.zip。 If not, choose the src.zip file which you have in your java installation directory.
如果没有,请选择您在 java 安装目录中的 src.zip 文件。 java source attach in eclipse Similarly, if you have the javadoc downloaded in your machine, you can configure that too in this dialog box.
java source attach in eclipse 同样,如果你在你的机器上下载了javadoc,你也可以在这个对话框中配置它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.