You have taken care to create solid XML schemas representing your data types and now you want to generate Java sources from them.
Use the XML/Java Compiler XJC tool that comes with Java to compile your schemas into
Java classes. If you’re using Ant, use Sun’s
Sun does not ship Ant tasks with Java SE, and the task for XJC is no exception. You can find it in the glassfish/lib directory webservices-tools.jar. You may also need webservices-rt.jar on the classpath as well.
The purpose of JAXB is to provide a convenient and easy way to bind an XML schema to its corresponding representation in a set of Java classes. It has two primary functions:
Creating XML document instances from Java objects
Creating Java objects from XML document instances
JAXB used to be a bit more difficult to use than it is now. The 1.0 version came with the Web Services Developer pack as a separate download, and because Java 5 annotations were not yet used, JAXB generated far more code during marshaling and unmarshaling. That code was tricky to read and more rigid to work with. For one thing, JAXB 1.0 generated Java interfaces for everything during unmarshaling, which bloated and complicated the code base, sometimes representing classes with counterintuitive names.
Java SE 1.6.0_05 comes with version 2.1.3 of JAXB. This includes the XJC tool in its bin directory, so as long as Java is on your path, which it ...