如果没有RT.Jar,如何使用Java Base类库?

发布于 2025-02-12 12:22:42 字数 474 浏览 0 评论 0原文

从: 为什么我们在Java项目中使用rt.jar?

我知道您需要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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

下壹個目標 2025-02-19 12:22:42

查看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 the java.base.jmod module file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文