是否可以替换 Java JRE 1.6 SE 中的 JAXB 实现版本? [英] Is it possible to replace the version of the JAXB implementation in Java JRE 1.6 SE?
本文介绍了是否可以替换 Java JRE 1.6 SE 中的 JAXB 实现版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个测试课
import javax.xml.bind.annotation.XmlElement;
class CompileTest {
void foo( @XmlElement String in ) {
}
}
我的java版本是
$ java -version
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode, sharing)
当我尝试编译那个类时,我得到了
and when I try to compile that class I'm getting
javac CompileTest.java
CompileTest.java:5: annotation type not applicable to this kind of declaration
void foo( @XmlElement String in ) {
^
1 error
这对 Java 6 有效.当我尝试将更新的 JAXB 库添加到类路径时,它没有帮助.有没有办法解决这个问题?
and that's valid for Java 6. When I tried to add newer JAXB library to class path, it didn't help. Is there a way to solve this?
javac -cp jaxb-api-2.2.4.jar CompileTest.java
推荐答案
使用 Java 认可的标准覆盖机制
将您的 jaxb-api-2.2.4.jar
放在
目录中.
Put your jaxb-api-2.2.4.jar
inside <java-home>\lib\endorsed
directory.
或者,使用 -D java.endorsed.dirs 选项
Or, use the -D java.endorsed.dirs option
javac -Djava.endorsed.dirs=/your/path/to/jaxb-directory CompileTest.java
参考文献:
http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
这篇关于是否可以替换 Java JRE 1.6 SE 中的 JAXB 实现版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文