Previous Up Next

6  Building Utool

So far, we have focused on how to use the complete Utool system as you download it, unchanged. This is sufficient in many scenarios – you can access Utool from the command line, you can connect to it as a server, and you can even implement your own Java classes that use our classes directly and add new codecs, as long as you simply add Utool.jar to your classpath. But there may be a point at which you want to recompile Utool. For such cases, we will now document how to unpack the Utool source distribution and recompile it.

The Jar file Utool-<version>.jar which you probably downloaded from the website only contains the compiled class files that are necessary for running the programme. This is the standard distribution because it is pretty small, and thus downloads and loads quickly.

If you want to recompile (parts of) Utool, you will need to download the source distribution. The source distribution has a filename of the form Utool-src-<version>.jar, and is some 4 megabytes in size. In addition to the Utool classes, it contains the source code of Utool, all classes of the iText, JGraphT, JGraph, and Getopt libraries that we use, and the javacc and testng Jars that are used in compiling Utool. The files in the source distribution Jar are in exactly the same locations as in the ordinary Jar, so in particular you can use the command java -jar Utool-src-<version>.jar to run Utool. In addition, you need the Java JDK 5.0 or higher, and you need Apache Ant 1.6 or higher.

Recompilation of Utool from the source distribution proceeds as follows:
  1. Unpack the Jar file in a new directory:
    $ jar xf Utool-src-<version>.jar
    


  2. Prepare for compiling by moving all files to the directories where the build script expects them:
    $ ant prepare
    


  3. Change or add classes as you like. The source code of all classes is under the directory src. If you add new classes, you may have to edit the Ant build script in build.xml.

  4. Recompile as follows:
    $ ant
    
    This will create the file Utool-<version>.jar in the directory build/lib, which you can run using java -jar as before.

Previous Up Next