Use Eclipse to read Java source code

Source: Internet
Author: User

Many times you want to read the Java source code (whether it comes with a JDK or a third party), but the jar package we use is a compiled class package that cannot be opened directly in eclipse, and we need to download the source package.

In this article, for example, HttpClient is a tool that Apache provides to access network resources using the HTTP protocol, which is more powerful than the methods provided by the JDK's java.net package. For example, I would like to read httpclient specific package of what methods, how to achieve it?

HttpClient HttpClient = new HttpClient ();

The procedure is as follows:

First step: View the specific version of the jar package in your code

CTRL + left mouse button, click to see the class or method will pop up the following dialog box

Click "Change attached Source", open a new dialog, click "Browser", in the new pop-up dialog box can see the version of the jar package used

Step two: Download the corresponding version of the source package

MAVEN Library Address

http://mvnrepository.com/

Search for "Commons-httpclient", the following is the desired

Select "Sources" in all packages in version 3.1, which is the source package

So visible, the source package is a few Java files

Step Three: Add the source Package

Select "External location" in the above dialog box and select the path to the source package on your hard disk, as shown in

Press CTRL + the left mouse button again, the source code will come out, you can also break the source of debugging points.

Use Eclipse to read Java 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.