XJC (XML Java Compiler) is part of JAXB (Java XML Bindings).
If I look at the official website, the latest version of JAXB seems to be 2.2.11. That's the one you got when you just install the latest JDK version 8u40.
The following output shows the version of XJC related to JDK 8u40:
../JDK8u40/bin$ ./javac -version
javac 1.8.0_40
../JDK8u40/bin$ ./xjc -version
xjc 2.2.8-b130911.1802
(The original JDK path differs from OS to OS, so this is just an exemplary representation.)
It seems the version of XJC differs to the "latest" JAXB version or the latest JDK does not contain the latest JAXB version.
My workaround is to just install the latest JAXB version from the Maven repository. Sounds easy, but why the latest version of JAXB is 2.2.12 now? Forgot to put the documentation on the offical website? Okay, I just try to don't care... After the successful installation process I noticed there is no XJC inside this package. So go on searching... I found another Maven repository with the name "JAXB-XJC". But this is just the source code. I simply want to install the latest binary of XJC. I looked at the version number, which is 2.2.11. That looks at least better than 2.2.8.
But where I can get the latest binary of XJC?
Why I want to install the latest binary of XJC? Because I want to know if it supports Optionals of Java 8 and/or if it supports XSD schema version 1.1. Somewhere on the Internet I read the latest XJC at least supports the XSD schema version 1.1. That would be enough for now. But to figure this out, it seems Oracle has to fix their horrible version chaos.
Update
I tried to build JAXB by cloning the official Git repository and doing mvn clean install
.
Result:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] JAXB BOM ........................................... SUCCESS [ 0.140 s]
[INFO] JAXB BOM with ALL dependencies ..................... SUCCESS [ 0.005 s]
[INFO] JAXB Reference Implementation ...................... SUCCESS [ 0.515 s]
[INFO] JAXB External parent ............................... SUCCESS [ 0.009 s]
[INFO] RNGOM .............................................. SUCCESS [ 3.723 s]
[INFO] Codemodel .......................................... SUCCESS [ 0.008 s]
[INFO] Codemodel Core ..................................... SUCCESS [ 2.622 s]
[INFO] Codemodel Annotation Compiler ...................... SUCCESS [ 0.848 s]
[INFO] JAXB TXW parent .................................... SUCCESS [ 0.006 s]
[INFO] TXW2 Runtime ....................................... SUCCESS [ 1.920 s]
[INFO] TXW2 Compiler ...................................... SUCCESS [ 1.507 s]
[INFO] JAXB Core .......................................... SUCCESS [ 1.745 s]
[INFO] JAXB Runtime parent ................................ SUCCESS [ 0.008 s]
[INFO] JAXB Runtime ....................................... SUCCESS [ 5.932 s]
[INFO] JAXB1 Runtime ...................................... SUCCESS [ 1.520 s]
[INFO] JAXB XJC ........................................... SUCCESS [ 5.555 s]
[INFO] JAXB JXC ........................................... SUCCESS [ 2.928 s]
[INFO] Parent for osgi testing modules. ................... SUCCESS [ 0.009 s]
[INFO] osgi-test-parent ................................... SUCCESS [ 1.315 s]
[INFO] osgi-test-core ..................................... SUCCESS [ 0.676 s]
[INFO] JAXB bundles ....................................... SUCCESS [ 0.007 s]
[INFO] Old JAXB Core ...................................... SUCCESS [ 4.669 s]
[INFO] osgi-test-runtime .................................. SUCCESS [ 0.677 s]
[INFO] Old JAXB Runtime ................................... SUCCESS [ 3.251 s]
[INFO] osgi-test-xjc ...................................... SUCCESS [ 0.637 s]
[INFO] Old JAXB XJC ....................................... SUCCESS [ 4.385 s]
[INFO] osgi-test-jxc ...................................... SUCCESS [ 0.607 s]
[INFO] Old JAXB JXC ....................................... SUCCESS [ 2.169 s]
[INFO] JAXB Documentation parent .......................... SUCCESS [ 0.005 s]
[INFO] JAXB Release Documentation ......................... SUCCESS [ 12.401 s]
[INFO] JAXB samples ....................................... SUCCESS [ 0.375 s]
[INFO] JAXB RI ............................................ SUCCESS [ 1.079 s]
[INFO] JAXB OSGI parent ................................... SUCCESS [ 0.005 s]
[INFO] JAXB extra OSGI .................................... FAILURE [ 6.668 s]
[INFO] JAXB OSGI .......................................... SKIPPED
[INFO] osgi-test-osgi ..................................... SKIPPED
[INFO] osgi-test-extra_osgi ............................... SKIPPED
[INFO] JAXB OSGi Tests .................................... SKIPPED
[INFO] JAXB WWW Help files ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:08 min
[INFO] Finished at: 2015-03-11T15:40:59+01:00
[INFO] Final Memory: 83M/1546M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade (default) on project jaxb-extra-osgi: Error creating shaded jar: java.util.jar.Attributes cannot be cast to java.lang.String -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :jaxb-extra-osgi
The build process always fails at the JAXB extra OSGI target. The JAXB XJC target builds successfully, but only contains a exceptions throwing jar file but no binary named xjc. So where is it?