How do I add the Java API documentation to Eclipse?

前端 未结 14 1423
名媛妹妹
名媛妹妹 2020-11-30 17:34

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

相关标签:
14条回答
  • 2020-11-30 18:07

    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.

    0 讨论(0)
  • 2020-11-30 18:07

    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 folder
    • locate "src.zip"
    • Eclipse: 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.

    0 讨论(0)
  • 2020-11-30 18:09

    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.

    0 讨论(0)
  • 2020-11-30 18:16

    Instead of attaching JavaDoc attach JDK src.zip

    0 讨论(0)
    1. Go to your JDK installation. (C:\Program Files\Java\jdk1.8.0_66 for me).

    2. Unzip the src.zip file (becomes C:\Program Files\Java\jdk1.8.0_66\src\ for me).

    3. In the Eclipse editor window: CTRL + Click on a java.lang library class. (something like String).

    4. Eclipse will complain Source not found and tell you that you don't have the source.

    5. Click Attach source -> External Location -> External Folder.

    6. Find your source folder (C:\Program Files\Java\jdk1.8.0_66\src\ for me).

    7. Click OK -> OK.

    8. Enjoy.

    0 讨论(0)
  • 2020-11-30 18:19

    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.

    0 讨论(0)
提交回复
热议问题