简体   繁体   English

jdk/jmods 中的 jmods 目录在应用程序运行时有什么作用吗?

[英]Does the jmods directory in jdk/jmods have any role during application runtime?

I have an application which runs in a sandbox environment using an OpenJDK.我有一个使用 OpenJDK 在沙盒环境中运行的应用程序。 The JDK directory has a jmods folder. JDK 目录有一个 jmods 文件夹。

The documentation regarding jmods isn't that great.关于 jmods 的文档不是很好。 From what I understand, jmods is useful if I want to create another custom JRE using JLink.据我了解,如果我想使用 JLink 创建另一个自定义 JRE,jmods 很有用。

Say, if I don't want to do that and just want to have a JDK which can build and run my Java SWT application.假设我不想这样做,只想拥有一个可以构建和运行我的 Java SWT 应用程序的 JDK。 Will it be safe to simply remove the jmods directory?简单地删除 jmods 目录是否安全?

Does the jmods directory in jdk/jmods have any role during application runtime? jdk/jmods 中的 jmods 目录在应用程序运行时有什么作用吗?

No. These are only archives that are used as input to jlink .不,这些只是用作jlink输入的档案。 The class files and other resources that are used during runtime are stored in the lib/modules archive, which is in a custom format that can be read for instance with the jimage tool.运行时使用的类文件和其他资源存储在lib/modules存档中,该存档采用自定义格式,例如可以使用jimage工具读取。 (or by JDK code using one of two jimage library implementations in the JDK) (或通过使用 JDK 中两个 jimage 库实现之一的 JDK 代码)

.jmod files are not meant to be used during execution. .jmod文件不打算在执行期间使用。 If you try to put a .jmod file on the module path, you even get an error:如果您尝试将.jmod文件放在模块路径上,您甚至会收到错误消息:

java.lang.module.FindException: JMOD format not supported at execution time: <some.mod>.jmod

Say, if I don't want to do that and just want to have a JDK which can build and run my Java SWT application.假设我不想这样做,只想拥有一个可以构建和运行我的 Java SWT 应用程序的 JDK。 Will it be safe to simply remove the jmods directory?简单地删除 jmods 目录是否安全?

If you use jlink to create a runtime image, it will not contain a jmods directory in the first place.如果您使用jlink创建运行时映像,它首先不会包含 jmods 目录。 So, there's nothing you should have to remove.因此,您无需删除任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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