JAXB 从 xsd 生成 java 类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2105426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JAXB generate java class from xsd
提问by dell
- JAXB 1.5 installed under C:\Sun\jwsdp-1.5
- J2SE 1.4.2 installed under C:\j2sdk1.4.2_08
- copied sample.xsd file to C:\Sun\jwsdp-1.5\jaxb\bin
- went to C:\Sun\jwsdp-1.5\jaxb\bin and ran xjc.bat -p com.package sample.xsd
- got error message: Unrecognized option: -pCould not create the Java virtual machine.
- JAXB 1.5 安装在 C:\Sun\jwsdp-1.5 下
- J2SE 1.4.2 安装在 C:\j2sdk1.4.2_08 下
- 将 sample.xsd 文件复制到 C:\Sun\jwsdp-1.5\jaxb\bin
- 去 C:\Sun\jwsdp-1.5\jaxb\bin 并运行 xjc.bat -p com.package sample.xsd
- 收到错误消息:无法识别的选项:-p无法创建 Java 虚拟机。
Please help me out, thanks a lot
请帮帮我,非常感谢
回答by Carsten
This page seems to indicate tha xjc.bat needs Java 1.5+ :
此页面似乎表明 xjc.bat 需要 Java 1.5+ :
回答by Andreas Dolk
The last JAXB version that is compatible with java 1.4.2 is JAXB 1.0.6. I've never heard of a version 1.5... Where did you get it?
与 java 1.4.2 兼容的最后一个 JAXB 版本是JAXB 1.0.6。我从来没有听说过 1.5 版……你从哪里得到的?
Edit
编辑
This error message is not generated by jaxb but by the JVM. Looks like, the jvm thinks, the '-p' parameter is a jvm parameter. Here's another pagewhere the same error message was generated at a simple java --versioncall.
此错误消息不是由 jaxb 生成的,而是由 JVM 生成的。看起来,jvm 认为,'-p' 参数是一个 jvm 参数。这是另一个页面,其中通过简单java --version调用生成了相同的错误消息。
And another explanationfor the error.
以及对错误的另一种解释。
回答by mohan babu
I faced the similar problem and I resolved it using the following approach. I specified Jdk1.5 as the JDK while installing jwsdp1.5. But the system had jdk1.4 also installed. So I created the following batch file:
我遇到了类似的问题,并使用以下方法解决了它。我在安装 jwsdp1.5 时指定了 Jdk1.5 作为 JDK。但是系统也安装了jdk1.4。所以我创建了以下批处理文件:
set JAVA_HOME=D:\apps\BEA\Weblogic\jdk150_04
set ANT_HOME=H:\Sun\jwsdp-1.5\apache-ant
set JWSDP_HOME=H:\Sun\jwsdp-1.5
set PATH=%JAVA_HOME%\bin;%PATH%;
%JWSDP_HOME%\jaxb\bin\xjc -p package -dtd sample.dtd
This resolved the error. Alternatively we can remove the Jdk1.4 path in the PATH environment variable, in that case, we need to write the batch file.
这解决了错误。或者我们可以把PATH环境变量中的Jdk1.4路径去掉,在这种情况下,我们需要编写批处理文件。

