Notification texts go here Contact Us Buy Now!

Where are the Java System Packages stored?

You can try unzipping/unjarring rt.jar, which is usually available in $JAVA_HOME/lib/rt.jar. The jar file should include the classfiles of all the JDK, if that is what you are asking about.

If you want a list of packages in the standard installation, just go to the Javadocs and look in the upper left corner.

If you want to see the .class files, they're in lib\rt.jar in the JRE directory (.jar is the same as .zip, so you can open it with anything that can open zip files).

If you want to see the source code, look in src.zip in the JDK directory. If it's not there, you probably elected not to install it when you installed the JDK.

Keep in mind that packages are represented as folders on disk, so you might be a little disappointed by what you see.

Assuming you mean the packages that include the class libraries like java.lang.* and java.util.*, these live in the "lib" directory under wherever your Java Runtime Environment (JRE) is installed.

On Windows, it would be something like this:

C:\Program Files\Java\j2re1.4.2_12\lib

In there, you should see files like rt.jar which contains the core Java classes and charsets.jar which contains many of the extended encoding support for EBCDIC and the CJK languages.

In a parallel bin directory are the executables for Java and related utilities.

If you've installed the Java Development Kit (JDK), in the directory above where you find the libs you will probably find a src.jar file. This can be unpacked either with the jar.exe utility or with a standard zip-style tool and contains the Java sources to the standard class library.

Some of Java, such as the virtual machine itself, is machine-specific and will be part of some of the DLL's or EXE's present.

My JDK 1.6.0_13 has a src.zip containing all the source code. Give that a look.

Windows:

For compressed compiled Java packages(Java Class Library, JCL):

program files/java/jdk/jre/lib/rt.jar

For source of packages:

program files/java/jdk/src.zip

We can use any unzipping software to look into them.

From Java 9 onwards rt.jar was removed

The class and resource files previously stored in lib/rt.jar, lib/tools.jar, lib/dt.jar, and various other internal JAR files are now stored in a more efficient format in implementation-specific files in the lib directory. The format of these files is not specified and is subject to change without notice.

The System class files can now be accessed as shown below

FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
Path objClassFilePath = fs.getPath("modules", "java.base", "java/lang/Object.class");

As answered by @VenkataRaju i would like to put 2 more points that

  1. we have ./bin, ./conf, ./include, ./jmods, ./legal, ./lib
  2. we can see all the classlist in ./lib/classlist and ./lib/src.jar in java 11

rt.jar is removed since Java 9. So, to find sources of JCL you should:


sudo find / -name java.base

In a JDK version 18.0.1.1, all packages are present in the jrt-fs.jar file.

path:- jdk-18.0.1.1\lib\jrt-fs.jar.

inside this jrt-fs.jar file, all pre-defined classes are present in the package path like java\io for java.io, java\lang for java.lang, java\util for java.util, java\sql for java.sql etc..

As some of the users mentioned already, it can be found at:


/Java/jdk-21/lib/src.zip/

Terminal need to be elevated to Admn mode: Win

Example: Java File method is under IO package.


/Java/jdk-21/lib/src.zip/java.base/java/io

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.