Is it possible to replace the version of the JAXB implementation in Java JRE 1.6 SE?

java, jaxb

Solution

Use the Java Endorsed Standards Override Mechanism

Put your `jaxb-api-2.2.4.jar` inside `<java-home>\lib\endorsed` directory.

Or, use the -D java.endorsed.dirs option

`javac -Djava.endorsed.dirs=/your/path/to/jaxb-directory CompileTest.java`

References: http://docs.oracle.com/javase/6/docs/technotes/guides/standards/

Problem

I have this test class ``` import javax.xml.bind.annotation.XmlElement; class CompileTest { void foo( @XmlElement String in ) { } } ``` my java version is ``` $ 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 ``` 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 ```

Original source

Related problems