如何在运行时包含Java 9模块? [英] How do I include a java 9 module at runtime?
问题描述
我有一个服务器套件,正尝试在java9 JDK上进行测试(在此处,我使用的是64位Linux版本),但是启动后不久就会遇到以下错误:
I have a server kit that I'm trying to test on the java9 JDK (found here, I'm using the 64-bit Linux version), however I'm encountering the following error shortly after startup:
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:533)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:186)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:476)
使用Java8时,服务器工具包启动没有问题.我需要以某种方式告诉运行时系统包括javax.xml.bind
模块,但是我是java9的新手,不知道如何将整个服务器工具包重新编译为模块并添加对
The server kit starts without issue when using java8. Somehow I need to tell the runtime system to include the javax.xml.bind
module, however I'm new to java9 and don't know how to do this short of recompiling the entire server kit into a module and adding a dependency on the javax.xml.bind
module. Is there a way to resolve this error that doesn't require me to recompile the server kit into a module?
推荐答案
Java EE modules are shipped with the JDK but not resolved by default and java.xml.bind is one of them. In such cases they need to be included explicitly with --add-modules
.
以您的情况为例,请使用--add-modules java.xml.bind
启动.
In your case, launch with --add-modules java.xml.bind
.
这篇关于如何在运行时包含Java 9模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!