本文介绍了使用Java 9将自定义JMOD添加到模块路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用这样的jmod工具创建了一个简单的 JMOD
文件
I created a simple JMOD
file with the jmod tool like this
$JAVA_HOME/bin/jmod create --class-path classes test/samples.jmod
Next ,我尝试通过运行在该模块中执行一个类:
Next, I tried to execute a class within that module by running:
java -mp test -m de.mypackage/de.mypackage.Test
导致以下异常:
Error occurred during initialization of VM
java.lang.module.ResolutionException: JMOD files not supported: test/samples.jmod
at java.lang.module.Resolver.findWithBeforeFinder(java.base@9-ea/Resolver.java:729)
at java.lang.module.Resolver.resolveRequires(java.base@9-ea/Resolver.java:86)
at java.lang.module.Configuration.resolveRequiresAndUses(java.base@9-ea/Configuration.java:370)
at java.lang.module.ModuleDescriptor$1.resolveRequiresAndUses(java.base@9-ea/ModuleDescriptor.java:1986)
at jdk.internal.module.ModuleBootstrap.boot(java.base@9-ea/ModuleBootstrap.java:263)
at java.lang.System.initPhase2(java.base@9-ea/System.java:1928)
如果我只设置我的类
目录(我曾经创建过)作为模块路径的JMOD文件),一切都按预期工作。
If I just set my classes
directory (that I used to create the JMOD file) as modulepath, everything is working as expected.
通常不可能有 JMOD
文件在模块路径?如果是这种情况,有什么理由吗?
Is it generally not possible to have JMOD
files on the modulepath? And if this is the case, is there any reason for that?
推荐答案
参见
这篇关于使用Java 9将自定义JMOD添加到模块路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!