对于Java程序员来说,有时候是需要查看JDK或者一些Java框架的源码来分析问题的,而默认情况下,你按住Ctrl,再点击Java本身的类库(例如ArrayList)是无法查看源码的,那么如何在Eclipse中查看JDK以及Java框架的源码呢?下面,跟着我一起,一步步带你走进源码的世界。
method One: Fast and easy
The first step:
Open your eclipse and look for a Java file, grab a Java class library, like a string, and then hold down CTRL and click on it, and you'll find the following interface:
You will find an error: Source not found. This is inevitable, do not be afraid, we continue to go down.
Step Two:
Clicking on the "Attach Source ..." button pops up a dialog box, then selects the External location option, then clicks on "External File ..." and then pops up the dialog, the whole process such as:
Step Three:
In the pop-up Jar/zip File selection dialog box, locate the Src.zip in the JDK installation directory. Then select, and then tap Open. Then click OK what's.
Fourth Step:
This time, you can choose a Java-brought class, then press CTRL, choose an open option, you will find that the miracle appears, as follows:
method Two: formal slightly complex
The first step:
Click "Window", "Preferences", "Java", "Installed JREs", the following dialog box appears:
Step Two:
Select your JRE and click on the "Edit ..." button on the right, and the following dialog box will appear:
Step Three:
In the box at the bottom left of the pop-up dialog, select the Rt.jar category, then expand the category, click Source Attachment under Category: (None), and then click on the "Source attachment ..." button on the right, and the following dialog box will appear:
Fourth Step:
Still is to find your Src.zip file, then open, then step by step OK or finish what, apply your configuration selection.
Fifth Step:
Here, you can happily look at the various source code, as for the other Java framework, such as spring, the setting method is similar, here will not repeat it.
How to view the JDK and Java Framework's source code in eclipse