How to attach source or JavaDoc in eclipse for any

2019-01-06 11:13发布

问题:

Presently I'm working with JavaFX. Whenever I hover over a method of JavaFX its gives me the following error:

'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?

回答1:

  1. Download jar file containing the JavaDocs.
  2. Open the Build Path page of the project (right click, properties, Java build path).
  3. Open the Libraries tab.
  4. Expand the node of the library in question (JavaFX).
  5. Select JavaDoc location and click edit.
  6. Enter the location to the file which contains the Javadoc (the one you just downloaded).


回答2:

You can configure the Javadocs with downloading jar, basically javadocs will be referred directly from internet.

Complete steps:

  1. Open the Build Path page of the project (right click, properties, Java build path).
  2. Open the Libraries tab.
  3. Expand the node of the library in question (JavaFX).
  4. Select JavaDoc location and click edit.
  5. Enter the location to the file which contains the Javadoc. Specifically for the javaFX javadoc enter http://docs.oracle.com/javafx/2.0/api/

for offline javadocs, you can download from : 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



回答3:

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. I hope is will be useful.



回答4:

Alternatively you can also,

1) Navigate to that method by Ctrl+Click on the method. The new tab/window will opened with text "Source not found" and button "Attach Source.." in it
2) Click the button "Attach Source.."
3) New window pops up. Click the button "External Folder"
4) Locate the JavaFX javadoc folder. If you are on Windows with default installation settings, then the folder path is C:\Program Files\Oracle\JavaFX 2.0 SDK\docs



回答5:

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. Another way to install the Javadocs is:

  1. Right click on the project, select Properties
  2. Select Libraries on the right side of the tab
  3. At the right top side of the tab, you may see "Default JavaFX Platform" or something similar. Click on the Manage Platforms button. (You can also install this default platform from here if you haven't got this already).
  4. In the Java Platform Manager tab which appears, select "Default JavaFX Platform" on the left side, and then click on the JavaFX tab on the right side of the window.
  5. One of the entry fields is labeled "JavaFX Javadoc". Click the "Browse" button next to this field and browse to the installed docs file mentioned above.

Hope this helps some people who were as puzzled as I was.



回答6:

First, if you get the message

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

Then it means that you've already included the external jar needed for your project.

The next step would be to associate the external jar with its javadoc url.

  • go to package explorer, expand your project folder, expand referenced libraries
  • right click the external jar that you want to associate its javadoc with
  • click properties -> javadoc location
  • copy and past the url for the javadoc that you googled online into the javadoc location path
  • click apply

And you're all set!



回答7:

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.

RightclickOnProject > Configuration > Convert in to Maven Project

- Now follow the steps:

1. Select any jar for which you want to download sources or javadocs.

2. RightClick > Maven > Download javadoc or Download javasources



回答8:

In addition to the answer of @dhroove (would have written a comment if I had 50 rep...)

The link has changed to: http://docs.oracle.com/javafx/2/api/

At least my eclipse wasn't able to use the link from him.



回答9:

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

Where can I download the JavaDoc for JPA 2.0?



回答10:

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. In my own Java source I selected an element I was using from the jar and hit F3 (Open declaration). Eclipse opened the class file and showed the button "Attach source". I clicked the button and pointed to the src jar file I had just put into the lib-src folder. Now I get the Javadoc when hovering over anything I’m using from the jar.



回答11:

If you are using maven just do:

mvn eclipse:eclipse -DdownloadSources=true  -DdownloadJavadocs=true