Attach the Java Source Code

前端 未结 14 1605
傲寒
傲寒 2020-11-28 23:37

I cannot for the life of me attach the java source code to eclipse so I can see the inner workings of the language. Not even something as simple as the String Class.

相关标签:
14条回答
  • 2020-11-28 23:58

    issue resolved here :

    "Windows/Preferences": Java > Installed JREs:

    then set/update JRE HOME : C:\Program Files\Java\jdk1.8.0_221\jre

    should try this.

    0 讨论(0)
  • 2020-11-29 00:01

    What worked for me (with JDK7) was the following:

    1. Download the openjdk-xy-sources.jar from GrepCode,
    2. rename the file to src.zip,
    3. copy src.zip to the root folder of the JRE/JDK added to eclipse (the one with bin and lib folders in it)
    4. restart eclipse

    Alternatively, if you don't want to write to your JDK folder, you could also attach src.zip to (at least) rt.jar in eclipse in the Window | Preferences menu in Java | Installed JREs.

    If you're not comfortable with downloading the sources from GrepCode, you could also get them from openJDK directly. This requires requires a bit more effort, though. Replace step one above by the following steps:

    1. Download the JDK sources from here,
    2. extract all folders from the zip file's *openjdk\jdk\src\share\classes* folder,
    3. create a file src.zip and add these folders to it,
    4. copy src.zip to the root folder of the JRE/JDK added to eclipse (the one with bin and lib folders in it)
    5. restart eclipse

    A third alternative to acquire src.zip is to download the unofficial OpenJDK builds from here. The src.zip is contained within the downloaded zip.

    0 讨论(0)
  • 2020-11-29 00:01

    enter image description here

    if you are add jre and jkd path, remove jre install path, keep jdk path is work

    0 讨论(0)
  • 2020-11-29 00:04

    The option provided by"praveenak" can also be applied to any other jar files with source file provided. For example, for JavaFx, we right click jfxrt.jar, select "Properties" and enter jdk1.8.0_05/javafx-src.zip for "Path" under External location.

    0 讨论(0)
  • 2020-11-29 00:05

    To attach JDK source so that you refer to Java Source Code for code look-up which helps in learning the library implementation and sometimes in debugging, all you have to do is:

    In your Eclipse Java Project > JRE Reference Library locate rt.jar. Right click and go to Properties:

    Select "Java Source Attachment" on the right and to the left select "External Location" and click on "External File" Button and locate "src.zip" file in your $JAVA_HOME path in my case for my windows machine src.zip location is: C:/Program Files/Java/jdk1.7.0_45/src.zip.

    You are done now! Just Ctrl + click on any Java library Class in your project code to look-up the source code for the java class.

    0 讨论(0)
  • 2020-11-29 00:05

    Just remove the JRE in Preferences>Java>Installed JRE and add the folder of your JDK. If you just add JDK but still leave JRE it won't work

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