How to view the JDK and Java Framework's source code in eclipse

Source: Internet
Author: User

    对于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

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.