Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: what's missing to generate JAXB XML bindings?

Tags:

eclipse

jaxb

I am using Eclipse Oxygen with a Java 8 runtime. I have an XML schema and I need to generate the corresponding XML -> Java bindings using JAXB. But when I right-click the .xsd File -> Generate -> JAXB classes..." and walk through the dialogs I get a warning "the classpath appears not to contain the necessary libraries to continue with class generation". And, indeed, when I proceed I end up in an exception "Error: Could not find or load main class com.sun.tools.internal.xjc.XJCFacade".

Now, to my knowledge, Java since v1.6 contains all necessary JAXB libraries and tools. So, why is this not working?

As a variant I ticked the checkbox to use Eclipe's built-in "MOXy" implementation, but that doesn't work, either.

I then googled and found that I need to make sure that I have chosen a runtime that contains JAXB (i.e. one >= v1.6) but that's obviously the case here.

What do I need to add/download/configure to get this going? Any pointers or instructions welcome!

like image 753
mmo Avatar asked Mar 07 '23 22:03

mmo


1 Answers

Googling again (obviously this time with better search terms) I found this post which provided the solution: the chosen runtime in Eclipse has to be a JDK, not a JRE!

Apparently only the JDKs contain the required tools/libraries to get this JAXB translation working. If only the error message would give a hint in that direction...

Adding the Java 8 JDK (which I had installed, too, besides the JRE) to the list of available runtimes in Eclipse and defining it as the default runtime did the trick.

like image 177
mmo Avatar answered Mar 10 '23 12:03

mmo