Building Tomcat

Once you've completed all of the above, you should be able to build a working Tomcat just by running the ant command in the top level of the Tomcat source tree. Before you do that, though, you need to set your Ant Java heap to a larger size than the default so that the build does not fail due to lack of memory:

$ export ANT_OPTS="-Xms1024M -Xmx1024M"

Then, you're ready to build Tomcat:

$ cd tc6.0.15
$ ant

If this process finds everything it needs, you should have a successful build. In only a minute or less (usually), you should have a shiny, brand new Tomcat server.

If you get an error message instead, you have to decide if it is a library compatibility issue or a genuine compilation error, and fix it. Usually, it's just a matter of providing the right versions of the right libraries and the right version of Java that will allow Tomcat to compile. If you really, truly fix an error in Tomcat, please feed it back to the developers via the mailing list (see Chapter 11 for details).

Once you get the BUILD SUCCESSFUL message, you have a nearly complete Tomcat distribution in the output/build subdirectory of your source tree. In order for it to run, it needs a logs directory and a work directory, plus the scripts in the bin/ directory need to be marked executable. To finish the build and create release archives of your Tomcat, run the release target in the dist.xml build file, like this:

$ ant -f dist.xml

This will create a distribution-ready build of Tomcat in the output/dist ...

Get Tomcat: The Definitive Guide, 2nd Edition 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.