Java 系统包存储在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1240387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where are the Java System Packages stored?
提问by asb
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?
我想查看所有的 java 包。包裹存放在我的机器中的什么位置?任何人都可以帮忙。我确实在 jdk 文件夹中搜索并找到了 awt.dll 和所有内容。但它只是少数。我能看到所有的吗?
回答by notnoop
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.
您可以尝试解压缩/解压 rt.jar,它通常在$JAVA_HOME/lib/rt.jar
. jar 文件应该包含所有JDK
.
回答by Michael Myers
If you want a list of packages in the standard installation, just go to the Javadocsand look in the upper left corner.
如果您想要标准安装中的软件包列表,只需转到Javadocs并查看左上角。
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).
如果您想查看 .class 文件,它们位于lib\rt.jar
JRE 目录中(.jar
与 相同.zip
,因此您可以使用任何可以打开 zip 文件的内容打开它)。
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.
如果要查看源代码,请在src.zip
JDK 目录中查找。如果它不存在,则您可能在安装 JDK 时选择不安装它。
Keep in mind that packages are represented as folders on disk, so you might be a little disappointed by what you see.
请记住,包在磁盘上表示为文件夹,因此您可能会对所看到的感到有些失望。
回答by lavinio
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.
假设您的意思是包含类库(如 java.lang.* 和 java.util.*)的包,它们位于安装 Java 运行时环境 (JRE) 的任何位置下的“lib”目录中。
On Windows, it would be something like this:
在 Windows 上,它会是这样的:
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.
在那里,您应该看到rt.jar
包含核心 Java 类和charsets.jar
包含许多对 EBCDIC 和 CJK 语言的扩展编码支持的文件。
In a parallel bin
directory are the executables for Java and related utilities.
在并行bin
目录中是 Java 和相关实用程序的可执行文件。
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.
如果您已经安装了 Java 开发工具包 (JDK),那么在上面找到库的目录中,您可能会找到一个src.jar
文件。这可以使用jar.exe
实用程序或标准zip样式工具解压缩,并包含标准类库的 Java 源代码。
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.
某些 Java(例如虚拟机本身)是特定于机器的,并且将成为某些 DLL 或 EXE 的一部分。
回答by duffymo
My JDK 1.6.0_13 has a src.zip containing all the source code. Give that a look.
我的 JDK 1.6.0_13 有一个包含所有源代码的 src.zip。看看吧。
回答by Venkataswamy
Windows:
视窗:
For compressed compiled java packages( Java Class Library, JCL): program files/java/jdk/jre/lib/rt.jar
对于压缩编译的java包(Java Class Library,JCL):program files/java/jdk/jre/lib/rt.jar
For source of packages: program files/java/jdk/src.zip
包源:program files/java/jdk/src.zip
we can use any unzipping software to look into them.
我们可以使用任何解压缩软件来查看它们。
回答by Venkata Raju
From Java 9 on wards rt.jar
was removed
从 Java 9rt.jar
开始移除病房
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.
以前存储在
lib/rt.jar
、lib/tools.jar
、lib/dt.jar
和各种其他内部 JAR 文件中的类和资源文件现在以更高效的格式存储在 lib 目录中的特定于实现的文件中。这些文件的格式未指定,如有更改,恕不另行通知。
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");
回答by Rahul Gupta
As answered by @VenkataRaju i would like to put 2 more points that
正如@VenkataRaju 的回答,我想再提出 2 点
- we have ./bin, ./conf, ./include, ./jmods, ./legal, ./lib
- we can see all the classlist in ./lib/classlist and ./lib/src.jar in java 11
- 我们有 ./bin, ./conf, ./include, ./jmods, ./legal, ./lib
- 我们可以在 java 11 中看到 ./lib/classlist 和 ./lib/src.jar 中的所有类列表