How do I add the Java API documentation to Eclipse?
JavaEclipseJavadocJava Problem Overview
I have downloaded Java API documentation from http://www.oracle.com/technetwork/java/javase/downloads/index.html#docs and have supposedly attached it to Eclipse using the
> Window->Preferences->Java->Installed > JREs->Edit->"Select rt.jar"->Javadoc > Location
And the location has been accepted and "Validates" just fine. However, for the life of me, I can't get Eclipse to show the Javadocs in the tooltip whene I hover over an item (for example in the declaration of an ArrayList). I have also restarted Eclipse in attempts to get it to work
What am I doing wrong?
Java Solutions
Solution 1 - Java
To use offline Java API Documentation in Eclipse, you need to download it first. The link for Java docs are (last updated on 2013-10-21):
Java 6
Page: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-doc-download-355137.html<br>
Direct: http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-apidocs.zip
Java 7
Page: http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html
Java 8
Page: http://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html
Java 9
Page:http://www.oracle.com/technetwork/java/javase/documentation/jdk9-doc-downloads-3850606.html
- Extract the zip file in your local directory.
- From eclipse
Window --> Preferences --> Java --> "Installed JREs"
select available JRE (jre6: C:\Program Files (x86)\Java\jre6 for instance) and click Edit. - Select all the "JRE System libraries" using Control+A.
- Click "Javadoc Location"
- Change "Javadoc location path:" from "http://download.oracle.com/javase/6/docs/api/" to "file:/E:/Java/docs/api/".
It must work as it works for me. I don't need Internet connection to view Java API Documentation in Eclipse anymore.
Solution 2 - Java
For offline Javadoc from zip file rather than extracting it.
Why this approach?
This is already answered which uses extracted zip data but it consumes more memory than simple zip file.
Comparison of zip file and extracted data.
jdk-6u25-fcs-bin-b04-apidocs.zip ---> ~57 MB
after extracting this zip file ---> ~264 MB !
So this approach saves my approx. 200 MB.
How to use apidocs.zip?
> 1.Open Windows -> Preferences
> 2.Select jre
from Installed JREs
then Click Edit...
> 3.Select all .jar
files from JRE system libraries
then Click Javadoc Location...
> 4.Browse for apidocs.zip
file for Archive path
and set Path within archive
as shown above. That's it.
>
> 5.Put cursor on any class name or method name and hit Shift + F2
Solution 3 - Java
Eclipse doesn't pull the tooltips from the javadoc location. It only uses the javadoc location to prepend to the link if you say open in browser, you need to download and attach the source for the JDK in order to get the tooltips. For all the JARs under the JRE you should have the following for the javadoc location: http://java.sun.com/javase/6/docs/api/. For resources.jar, rt.jar, jsse.jar, jce.jar and charsets.jar you should attach the source available here.
Solution 4 - Java
Old question, but I had current problems with this issue. So I provide you my solution. Now the sources and javadocs are inside the jdk. So, unzip your jdk version.You can see that contanins a "src.zip" file. Here are your needed sources and doc files. Follow the path: Window->Preferences->Java->Installed JREs-> select your jre/jrd and press "Edit" Select all .jar files, and press Source Attachement. Select the "External File..." button, and point it to src.zip file.
Maibe a restart to Eclipse is needed. (normally not) Now you should see the docs, and also the sources for the classes from jdk.
Solution 5 - Java
I went through the same problem and I did not find some of the above answer useful because they are old and with new JDK 1.8 , documentation section has been moved to src.zip in JDK folder (C:\Program Files\Java\jdk1.8.0_101 ) .
Now I tried everything from above and it was showing me the same problem if I press ctrl and click on (for example String or System) in my program I get the Source not found.
Now you can do this, go to the folder where JDK (C:\Program Files\Java\jdk1.8.0_101) is installed and try to unzip src.zip. Here you might face an issue as sometime due to administrative rights on this folder it would not allow you to unzip this src.zip. For solving the issue , copy src.zip and paste in any other folder ( example Desktop) and then create a folder src and unzip in it. Now copy this folder back to JDK 1.8 folder**(C:\Program Files\Java\jdk1.8.0_101).**
Now just go to eclipse and open any program and press ctrl and click on any external objects or anything (for example String or System) .You will get Source not found , Now Click Attach source -> External Location -> External Folder and add your src location (C:\Program Files\Java\jdk1.8.0_101\src). Now you are good to go , I tried and it worked for me.
All the above folder location are from my system , so It might be different for you.
Solution 6 - Java
-
Go to your JDK installation. (
C:\Program Files\Java\jdk1.8.0_66
for me). -
Unzip the
src.zip
file (becomesC:\Program Files\Java\jdk1.8.0_66\src\
for me). -
In the Eclipse editor window:
CTRL + Click
on ajava.lang
library class. (something likeString
). -
Eclipse will complain
Source not found
and tell you that you don't have the source. -
Click
Attach source
->External Location
->External Folder
. -
Find your source folder (
C:\Program Files\Java\jdk1.8.0_66\src\
for me). -
Click
OK
->OK
. -
Enjoy.
Solution 7 - Java
Likely a problem with the path that you specified in Javadoc Location. It is pretty finicky. Make sure that it points at the root of where the javadoc starts. It could be a few directories down in the zip you've downloaded.
Solution 8 - Java
I have had a similar issue and looks like that the culprit was the space in the path to the archive (e.g., C:\Program Files\java\jdk). After moving the archive to another directory without spaces in path it started to work.
Solution 9 - Java
Solution 10 - Java
Choose one class you want to view its documentation and press Ctrl+click over it, the Javadoc page will inform you that there is no Javadoc file attached and bellow will see a button named "Attach File". Press that button and browse to the directory where JDK is installed, normally for Win is C:\Program files\Java\jdk_xxx and inside this folder there is a src.zip file - sleect it and press OK and all is done - you already have Javadoc attached.
Solution 11 - Java
For OpenJDK 8 on Linux see: https://askubuntu.com/questions/755853/how-to-install-jdk-sources
The way that worked for me is:
- The default
src.zip
is a symbolic link pointing to a non-existing folder ... sudo apt-get install openjdk-8-source
this adds this folderlocate "src.zip"
- Eclipse:
Window --> Preferences --> Java --> "Installed JREs"
, edit and point tosrc.zip
(or open any JRE class like for example HashMap and attach source)
You should now see the JavaDoc when opening JRE classes via Ctrl+Shift+t, previously this was not possible, Eclipse may have got a docs from the default URL on mouse over methods but this requires a stable internet connection.
Solution 12 - Java
Ensure "Preferences" -> "Java" -> "Editor" -> "Hovers" -> "Combined Hover" is checked.
Solution 13 - Java
I just had to dig through this issue myself and succeeded. Contrary to what others have offered as solutions, the path to my happy ending was directly correlated to JavaDoc. No "src.zip" files necessary. My trials and tribulations in the process involved finding the CORRECT JavaDoc to point at. Pointing a Java 1.7 project at Java 8 Javadoc does NOT work. (Even if "jre8" appears to be the only installed JRE available.) Thus, I beat my head against the brick wall unnecessarily.
Window > Preferences > Java > Installed JREs
If the JRE of your project is not listed (as happened to me when I migrated a jre7 project to a new jre8 workspace), you will need to add it here. Click "Add..." and point your Workspace at the desired jre folder. (Mine was C://Program Files/Java/jre7). Then "Edit..." the now-available JRE, select the rt.jar, and click "Javadoc Location..." and aim it at the correct javadoc location. For my use:
For jre7 -- http://docs.oracle.com/javase/7/docs/api/ For jre8 -- http://docs.oracle.com/javase/8/docs/api/
Voila, hover tooltip javadoc is re-enabled. I hope this helps anyone else trying to figure this problem out.
Solution 14 - Java
if you are using maven:
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true