Generating Java Source Files
At this point, you’ve got all of the required components to generate source code from the movie database constraint set. In this section, I detail the actual process of using the command-line tools in JAXB to generate classes. You’ll find out how to get set up with the JAXB framework, use the provided scripts, and actually generate classes.
Getting Set Up
The first thing you need to do, if you haven’t already, is download the JAXB release. Visit http://java.sun.com/xml/jaxb and follow the links to download the reference implementation of JAXB. I also recommend that you download the PDF specification for reference. Once you’ve got the release (named something like jaxb-1_0-bin.zip), you’ll want to extract this to a directory on your hard drive. On my Windows machine, I used c:\dev\javajaxb\jaxb-1.0, and it’s extracted at /dev/javajaxb/jaxb-1.0 on my Mac (running OS X).
You’ll want to note the two jar files in the lib/ directory, jaxb-rt-1.0-ea.jar and jaxb-xjc-1.0-ea.jar. The first is used for JAXB classes at runtime (indicated by the rt), and the second contains the classes used in schema compilation. In other words, you’ll want the first in your classpath for your applications using generated classes and the second in your classpath when generating those classes.
Additionally, JAXB comes with a script in the bin/ directory, used for invoking the Java class that starts the schema compiler for class generation. However, at least in the version I’ve got, ...