Invoking XJC from command line
The JAXB RI distribution ships with xjc.sh and xjc.bat for invoking XJC from a command prompt. JWSDP also has xjc.sh and xjc.bat, but their contents are different.
I'm sure these files are there for a reason, but personally, I hate those scripts. Here are why.
One, it's hard to set the JVM parameters, even though sometimes you need to increase the VM memory size to have XJC compile a large schema (at least with 1.0.) Even worse, the way you do it for the JAXB RI distribution and the way you do it for JWSDP are different (argh!)
Two, scripts tend to be poorly written. In a batch file or a shell script, you have to quote things just right, or it fails in some very specific circumstances. We are Java experts, but not shell scripting experts. We also observed some behavior difference between Solaris, Linux, and cygwin. Microsoft has its own share of problems; they expanded the batch file syntax, but there's no authoritative documentation of what feature is available on which platform. So poor test team need to run it on a large number of platforms, and even that doesn't cover everything.
Three, xjc.sh/xjc.bat in JWSDP works in a surprisingly convoluted way. It first launches a JWSDP's "launcher" program, which in turn invokes Ant, which runs XJC's ant task to get the job done. It somehow manages to use two VMs in this process. It's really beyond me why so much is necessary to just invoke the com.sun.tools.xjc.Driver.main method.
I'm sure many users have hit one of those problems themselves. So, here's the better way to invoke XJC:
$ java -jar /path/to/jaxb/lib/jaxb-xjc.jar options
Yep, that's it. This is guaranteed to work on all platforms, be it Windows, cygwin, Solaris, or Linux. It works both in standalone JAXB RI or JWSDP. No whitespace handling problem anymore, and every Java programmer knows how to increase a VM size. Oh, don't forget to say bye-bye to JAXB_HOME, JWSDP_HOME, or JAVA_HOME that you may require.
It's really a mystery to me that why we still think "xjc.sh" and "xjc.bat" are worth all these pain.
P.S. On Windows, shouldn't we register the jar extension to be executable? So that people can just type "foo.jar" instead of "java -jar foo.jar"?