如何在运行时包含Java 9模块? [英] How do I include a java 9 module at runtime?

查看:87
本文介绍了如何在运行时包含Java 9模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务器套件,正尝试在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?

推荐答案

JDK附带了Java EE模块,但

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆