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