简体   繁体   中英

Where are the Java System Packages stored?

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?

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.

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");

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.

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.

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.

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

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自 Java 9 以来已被删除。因此,要查找 JCL 的源代码,您应该:

sudo find / -name java.base

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM