Installing XOM


XOM is a library. By itself, it doesn't do much of anything. It exists only to be used by other programs. It requires Java 1.5 or later.

To install it you'll need to place the XOM JAR archive somewhere in your CLASSPATH. This archive is the file named something like xom-1.3.9.jar. (The version number may have changed if I've forgotten to update this document.) You can either put it in your jre/lib/ext directory, add xom-1.3.9.jar to your CLASSPATH environment variable, or use the -classpath option when invoking javac and java.

To check your download you can run one of the sample programs found in the xom-samples.jar file. For instance, nu.xom.samples.PrettyPrinter class formats an XML document by inserting and removing white space around element boundaries. In Java 1.4 and later you can run it from the command line like this:

$ java -classpath xom-samples.jar:xom-1.3.9.jar nu.xom.samples.PrettyPrinter filename.xml

The versions of xalan.jar, xercesImpl.jar, and xml-apis.jar found in the lib directory are quite a bit faster and less buggy than the ones bundled with the JDK, so you may well want to use them. For example,

$ java -classpath xom-samples.jar:xom-1.3.9:lib/xml-apis.jar:lib/xercesImpl.jar:lib/xalan.jar nu.xom.samples.PrettyPrinter filename.xml

You can leave out xalan.jar if you don't use any of the classes in nu.xom.xslt. junit.jar is only used for testing, and is not needed for normal operation of XOM.