[英]How to Run XJC in Java 9+
I downloadedJAXB 2.3.0.1 and JavaBeans Activation Framework (JAF) 1.2.0 (based on the answer to this question ).我下载了JAXB 2.3.0.1和JavaBeans Activation Framework (JAF) 1.2.0 (基于对这个问题的回答)。 I extracted all JAR files to the same directory, then run the following command within that directory:
我将所有 JAR 文件解压缩到同一目录,然后在该目录中运行以下命令:
java -cp jaxb-api.jar;jaxb-core.jar;jaxb-impl.jar;javax.activation-1.2.0.jar
-jar jaxb-xjc.jar [xjc-arguments]
The above command fails with the following message:上述命令失败并显示以下消息:
java.lang.NoClassDefFoundError: javax/activation/DataSource
java.lang.NoClassDefFoundError: javax/activation/DataSource
......
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource引起:java.lang.ClassNotFoundException:javax.activation.DataSource
I have verified that class exists within the javax.activation-1.2.0.jar file.我已验证 javax.activation-1.2.0.jar 文件中存在该类。 I have also tried using the new (to Java 9+) arguments
-p . --add-modules java.activation
我也尝试过使用新的(Java 9+)参数
-p . --add-modules java.activation
-p . --add-modules java.activation
, but that fails with the following error message: -p . --add-modules java.activation
,但失败并显示以下错误消息:
Error occurred during initialization of boot layer
启动层初始化时出错
java.lang.modules.ResolutionException: Modules jaxb.core and jaxb.impl export package com.sun.xml.bind.marshaller to module java.activationjava.lang.modules.ResolutionException:模块 jaxb.core 和 jaxb.impl 将包 com.sun.xml.bind.marshaller 导出到模块 java.activation
If I try a combination of -cp
and --add-modules
, I get a different boot layer initialization error.如果我尝试组合使用
-cp
和--add-modules
, -cp
--add-modules
不同的引导层初始化错误。 Does anyone know how to get XJC to run using a Java 9+ platform?有谁知道如何让 XJC 使用 Java 9+ 平台运行?
My specific use case is OpenJDK 11 on Windows.我的具体用例是 Windows 上的 OpenJDK 11。
The primary issue was that the java executable doesn't support specifying both the -cp
and -jar
command-line arguments at the same time.主要问题是java可执行文件不支持同时指定
-cp
和-jar
命令行参数。 Thanks to Alan Bateman for that information!感谢 Alan Bateman 提供的信息!
Therefore, the correct way to get this to work is by using the following command:因此,使其正常工作的正确方法是使用以下命令:
java -cp javax.activation-1.2.0.jar;jaxb-xjc.jar com.sun.tools.xjc.XJCFacade
[xjc-arguments]
In order to simplify running XJC, open bin/xjc.bat (extracted from jaxb-ri-2.3.0.zip), and edit the command line to match the above call.为了简化运行XJC,打开bin/xjc.bat (从jaxb-ri-2.3.0.zip中提取),编辑命令行匹配上面的调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.