如果没有RT.Jar,如何使用Java Base类库?
我知道您需要rt.jar才能使用基类库,例如java java.util
。
新的Java SDK中没有“ rt.jar”。如果我要从.java
文件中使用.class
文件,该文件使用Java base类库中的库,例如java.util
,如果我不能引用“ rt.jar”,我将如何运行它?
根据我的理解,在制作可运行的JAR文件时,您可以使用classPath
引用JAR中使用的其他库。现在,在没有“ rt.jar”的情况下制作罐子时,如何引用基类库?
From:
Why do we use rt.jar in a java project?
I get that you need rt.jar to be able to use a base class library such as java java.util
.
There is no "rt.jar" in the new java SDK. If I were to have a .class
file compiled from a .java
file that uses a library from the java base class libraries such as java.util
, how would I be able to run it if I can't reference "rt.jar"?
From my understanding when making a runnable jar file you use classpath
to reference other libraries used in the jar. How can I reference the base class libraries when making a jar now that there is no "rt.jar"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看JDK安装的
JMOD
文件夹 -.jmod
文件中包含JDK的模块(每个包含.class
和/of/和/<代码> .so 文件)。您可以使用
bin/jmod
工具来列出内容,提取或创建.jmod
文件。如果您需要检查.class
对应于.java
源文件的内容,则可以提取.class
这些.jmod
文件中的文件。例如,
java.util
类位于java.base.jmod
模块文件中。Look into the
jmods
folder of your jdk installation - the.jmod
files contain the modules of the JDK (each contains.class
and/or.so
files).You can use the
bin/jmod
tool to list contents, extract, or create.jmod
files. If you need to inspect the contents of the.class
files that correspond to.java
source files from the JDK, you can extract the.class
files from these.jmod
files.For example, the
java.util
classes are in thejava.base.jmod
module file.