How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
Asked Answered
H

13

84

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?

Haema answered 26/3, 2012 at 10:25 Comment(2)
Refer to this answer for referring javadoc offline. https://mcmap.net/q/246739/-how-do-i-add-the-java-api-documentation-to-eclipseWiseman
The fact that this post is so highly upvoted and the fact that it is so vague yet tries to be general is misleading. If someone wants to attach source for JavaFX to eclipse, I suggest they use this link: #58355161 This post here really does not help people with the specific problem of attaching source for JavaFX to eclipse.Joint
H
56

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

Haema answered 27/3, 2012 at 7:44 Comment(3)
This is almost same answer as Dennis Laumen'sButlery
You didn't ask the link in the question. You asked how attach javadoc to any jar file. You should know that most of the time you will get javadoc as jar file. Instead of writing almost identical 6 steps, you could add link as a comment to Dennis Laumen's answer. Anyways.Butlery
In my case, I had to link to http://htmlunit.sourceforge.net/apidocs/ and not http://htmlunit.sourceforge.net/apidocs/index.htmlCliquish
I
77
  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).
Incidentally answered 26/3, 2012 at 10:33 Comment(1)
I assume it's in the JavaFX SDK download. I would search for it there if I were you.Incidentally
H
56

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

Haema answered 27/3, 2012 at 7:44 Comment(3)
This is almost same answer as Dennis Laumen'sButlery
You didn't ask the link in the question. You asked how attach javadoc to any jar file. You should know that most of the time you will get javadoc as jar file. Instead of writing almost identical 6 steps, you could add link as a comment to Dennis Laumen's answer. Anyways.Butlery
In my case, I had to link to http://htmlunit.sourceforge.net/apidocs/ and not http://htmlunit.sourceforge.net/apidocs/index.htmlCliquish
B
19

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 it will be useful.

Borstal answered 18/1, 2013 at 8:55 Comment(2)
+10 if I could, finally got it working! Thanks! I just moved the library in question "up" until it was at the top of the list, and left it unchecked.Assemblyman
Yes, for some reason in my case it has to be above Android Private Libraries. Presumably the latter is terminating the search for the docs. Thanks!Tirpitz
A
5

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

Aerograph answered 26/3, 2012 at 14:30 Comment(2)
using a clean luna package and targeting jre 8, this was the simplist way to add "C:\Program Files\Java\jdk1.8.0_11\javafx-src.zip"Cervantez
I followed your method with JavaFX11, in the JavaFX SDK folder under the lib folder should be a .zip file with source. Adding that added javadoc for all JavaFX11 classes.Howlet
S
4

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!

Shayn answered 1/6, 2015 at 14:33 Comment(0)
A
4

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

enter image description here - 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

enter image description here

Abarca answered 24/7, 2017 at 7:27 Comment(0)
A
2

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.

Annunciation answered 27/6, 2012 at 12:40 Comment(0)
D
1

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.

Deirdredeism answered 26/9, 2014 at 9:26 Comment(0)
V
0

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?

Void answered 20/10, 2015 at 19:13 Comment(0)
H
0

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.

Hoye answered 11/2, 2016 at 13:39 Comment(0)
P
0

If you are using maven just do:

mvn eclipse:eclipse -DdownloadSources=true  -DdownloadJavadocs=true
Petie answered 26/7, 2016 at 7:16 Comment(0)
B
0

You could specify the online Javadoc location for a particular JAR in Eclipse. This saved my day when I wasn't able to find any downloadable Javadocs for Kafka.

  1. In the 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.
  2. Click on Javadoc Location.
  3. In the Javadoc location path field under Javadoc URL, enter the URL of the online Javadocs, which most likely ends with /<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).
Beverlee answered 26/7, 2019 at 6:49 Comment(0)
A
0

To attach the Java source code with Eclipse,

When you install the JDK, you must have selected the option to install the Java source files too. This will copy the src.zip file in the installation directory. In Eclipse, go to Window -> Preferences -> Java -> Installed JREs -> Add and choose the JDK you have in your system. Eclipse will now list the JARs found in the dialog box. There, select the rt.jar and choose Source Attachment. By default, this will be pointing to the correct src.zip. If not, choose the src.zip file which you have in your java installation directory. java source attach in eclipse Similarly, if you have the javadoc downloaded in your machine, you can configure that too in this dialog box.

Allred answered 21/7, 2020 at 23:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.