Installation and Setup

Getting Castor set up for use is just as simple as setting up Zeus; after a download and some classpath manipulation, you are ready to go. First, visit the Castor download site at http://castor.exolab.org/download.html, and download the Castor package. As of this writing, the latest version was 0.9.3.9, so the download file was called castor-0.9.3.9.tgz or castor-0.9.3.9.zip. Several other options for downloading are worth mentioning:

castor-0.9.3.9.jar

The Castor jar files without any tools or examples

castor-0.9.3.9-xml.jar

For use if you need only XML data binding, without any of Castor’s other mapping features

castor-0.9.3.9-doc.tgz

A complete set of Castor documentation, including relevant specifications; handy for reference purposes

Once you’ve got the archive, you’ll want to expand it into a working directory so you can access the samples and command-line tools. You’ll then need to add the Castor library to your classpath:

C:\dev\castor> set CLASSPATH=%CLASSPTH%;c:\dev\castor\castor-0.9.3.9.jar

Also make sure you have an XML parser in your classpath; I used xerces.jar in these examples. There are several other libraries in the Castor download, but you will not need any of them for XML data binding. However, if you plan to work with Castor’s Java Data Objects (JDO) capabilities (see the end of this chapter for more details), then you will also need to add jdbc-se2.0.jar and jta1.0.1.jar to your classpath.

Additionally, you will want to download ...

Get Java & XML Data Binding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.