View Java Source In Eclipse for Windows

As my journey into java development continues, I found an opportunity to investigate core java source code. My interest was the method String.contentEquals(). Curious in the difference between String.equals() and String.contentEquals(), look to java source code.

UPDATE: View Java Source In Eclipse for Windows – The Easy Way

Please note, I am not attempting to compile my own jdk library.  Information for compiling the jdk from scratch can be found here Also the openjdk will contain more source code than Oracle JDK.

Finally there are sites like that you can view source there if you like.

The following steps outline how I load java source code into eclipse for easy viewing.



Download the .gz file.  In my environment I am running x64.

The reason I am using the linux build is because the jt.jar file contains a few classes that don’t exist in the windows build.


Right click on .gz file > 7-Zip > Extract Here

Right click on non .gz file > Extract Here


A new folder will be created, browse to new folder, locate

Right click > 7-Zip > Extract to “\src”


A src folder will be created.


Next, open your eclipse and create a new java project. The new java project should have a src folder.


Right click on the eclipse src folder > Properties, take note of the Location.


Copy the contents of the extracted jdk src folder into the src of your java project.

In my example, I have D:\jdk\jdk1.7.0_51\src > C:\Lab\JavaSource\src


Refresh your project in eclipse.


You will notice right away of access restriction build problems.  Lets resolve these problems.

In eclipse, right click on your project > Properties > Java Build Path > Libraries


Click on the JRE System Library > Remove

Click Add Library > JRE System Library > Alternate JRE > Finish > OK


You will notice we still have a few problems.


This is the reason I am using the linux build, the jt.jar file contains the UNIXToolkit class that doesn’t exist in the windows build.

Lets resolve these problems

Right click on your project > Properties > Java Build Path > Libraries > Add External JARs…

Locate the rt.jar from your jdk download.  My locations was \jdk1.7.0_51\jre\lib.

Click OK


There should be no more problems, you are now able to inspect java source in eclipse editor.


Posted in Java
One comment on “View Java Source In Eclipse for Windows
  1. […] a previous post I outlined the steps to view java source code in […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: