问题
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?
回答1:
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.
回答2:
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");
回答3:
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.
回答4:
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.
回答5:
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.
回答6:
My JDK 1.6.0_13 has a src.zip containing all the source code. Give that a look.
回答7:
As answered by @VenkataRaju i would like to put 2 more points that
- we have ./bin, ./conf, ./include, ./jmods, ./legal, ./lib
- we can see all the classlist in ./lib/classlist and ./lib/src.jar in java 11
来源:https://stackoverflow.com/questions/1240387/where-are-the-java-system-packages-stored