Where are the Java System Packages stored?
Asked Answered
R

10

23

I want to see all the java packages. Where are the packages stored in my machine? Can anyone help. I did search in jdk folder and found awt.dll and all. But its only a few. Can i see all of them?

Raglan answered 6/8, 2009 at 17:42 Comment(1)
What OS are you dealing with?Pail
F
32

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.

Funnel answered 6/8, 2009 at 17:45 Comment(0)
K
24

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");
Kersten answered 22/12, 2018 at 15:36 Comment(2)
How to call this in python? , we have a python script where we used rt.jar, now after upgrading java we are facing errorsCompliant
@AnujMittal you would need to downgrade Java (yes)Sackman
S
6

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.

Sock answered 6/8, 2009 at 17:46 Comment(0)
A
5

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.

Angry answered 6/8, 2009 at 17:45 Comment(0)
T
3

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.

Tridentum answered 4/2, 2014 at 3:9 Comment(0)
G
1

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

Geraint answered 6/8, 2009 at 23:34 Comment(0)
A
1

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
Autograft answered 8/8, 2019 at 7:18 Comment(0)
C
0

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

sudo find / -name java.base
Cockspur answered 13/7, 2022 at 7:22 Comment(0)
T
0

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..

Tibbitts answered 22/5, 2023 at 3:13 Comment(0)
M
0

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

Mason answered 17/2, 2024 at 4:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.