怎么改整合包默认java路径,使用Java 9将自定义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, I tried to execute a class within that module by running:

java -mp test -m de.mypackage/de.mypackage.Test

Which resulted in the following exception:

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)

If I just set my classes directory (that I used to create the JMOD file) as modulepath, everything is working as expected.

Is it generally not possible to have JMOD files on the modulepath? And if this is the case, is there any reason for that?

解决方案

JMOD files can be used at compile time and link time, but not at run

time. To support them at run time would require, in general, that we

be prepared to extract and link native-code libraries on-the-fly. This

is feasible on most platforms, though it can be very tricky, and we

have not seen many use cases that require this capability, so for

simplicity we have chosen to limit the utility of JMOD files in this

release.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值