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
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.
For OpenJDK 8 on Linux see: https://askubuntu.com/questions/755853/how-to-install-jdk-sources
The way that worked for me is:
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"
Window --> Preferences --> Java --> "Installed JREs"
, edit and point to src.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.
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.
Instead of attaching JavaDoc attach JDK src.zip
Go to your JDK installation. (C:\Program Files\Java\jdk1.8.0_66
for me).
Unzip the src.zip
file (becomes C:\Program Files\Java\jdk1.8.0_66\src\
for me).
In the Eclipse editor window: CTRL + Click
on a java.lang
library class. (something like String
).
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.
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.