Eclipse Import JDK Source code

Source: Internet
Author: User

1. Always want to take a good look at the JDK source code, although you can directly unzip the JDK installation directory under the Src.zip file to see, but ultimately inconvenient; later know the use of Eclipse development can directly view the underlying source code, here is summed up the method found on the Internet, the following to share with you:
I believe many friends have encountered this problem: the development process will often look at the referenced classes (interfaces or methods) of the source code, but often in the JDK to view the class (interface or method) when the prompt page "source not found", This is because the default set of Eclipse's own JDK is not the source SRC, then how to introduce the JDK and framework of the source code?
Supplement: View the source method of the referenced class (interface or method):
Method One: Right-click the class (interface or method) name, select Open declaration or directly press F3 key, you can enter the source code.
Method Two: Often hold down the CTRL key, click on the class (interface or method) name, you can enter the source code.
Here are 3 ways to set up: (see Spring, Hibernate, struts and other frameworks source code needs to download their source files, set the same way)
1. Click the "Attach Source ..." button to add the source file:
Hold down the CTRL key and click on the class (interface/method) you want to view or select the class (interface or method) you want to view right-click Open declaration or press F3 to appear on the prompt page "source not found" on the "Attach Source ..." button on the page. Click the "External File ..." button in the pop-up window to find the JDK source src Click OK button, set to complete;
General JDK source code in the installation directory has a file called: Src.zip is, if it is the spring method, in the same way, add Spring source files of the compressed package (should be downloaded separately).
Add source files under 2.window->perference->java->installed jres option:
Before adding the source file, note that under Window->perference->java->build path->classpathvariable you can see that there is a jre_src variable that is empty and is marked as immutable. The variable is responsible for setting the source code path, but the variable is not modifiable and must be automatically detected by the system. In fact, the JDK source code in the installation time has been placed in the JDK directory, but Eclipse uses no source of the JRE, resulting in no corresponding source code;
Select Window->perference->java->installed JREs, change the default selected JDK in the popup window to a custom source (no click "Add ..." To add, or click "Search ..." Button search), save after modification;
Click window->perference->java->installed jres->search to find the directory where the JDK is located, then click OK to use the JRE, this should be the source.
3. The 3rd method of matching, care for people who do not understand:
Step1: Open Eclipse Selection window->preference;
Step2: Choose java->installed jres;

Step3: Select the JRE you installed and click Edit to enter the edit JRE as follows:
Step4: Check Rt.jar, click Source Attachment;

STEP5: In the dialog box, click External Folder, select the JDK directory you installed src.zip file, OK;
This completes the JDK source code import, select your own source code Java API list and other class library right-click Open decleration or F3 or ctrl clicks to see the source code;


Eclipse Import JDK Source code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.