Source code for the Java library classes

Viewed 32524

Where can I find the source code for the Java library classes? I mean classes in rt.jar.

Platform: Windows.

8 Answers

For old versions of Java with separate JRE and JDK downloads, download the JDK. The sources for the public classes are in src.zip.

Sources are in src.zip located in the installation folder:

  • On Windows, the JDK includes src.zip by default if I remember well.

  • On a Linux distro, you may have to install the sun-java6-source package.

  • On Mac, you'll have to download the Developer Documentation. Have a look at this answer.

If you only need to have a look at the source/implemenation, i would suggest using

Docjar

Edit

GrepCode is even better

GrepCode

You can directly browse the code online here for Java : https://zgrepcode.com/java/openjdk/10.0.2/

It is a great tool also for browsing most of the open source projects as it gives you internal linking to classes.

As mention above, most of the source files can be found by downloading the SDK. However for some classes you can find the source code (javax.ssl etc') for I suggest adding the jad eclipse plugin that will decompile any class without using external site such as Docjar. Jad eclipse info: http://jadclipse.sourceforge.net/wiki/index.php/Main_Page

Related