O'Reilly logo

Tomcat: The Definitive Guide, 2nd Edition by Ian F. Darwin, Jason Brittain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automation with Apache Ant

If you are changing your web application periodically and have to perform these various steps for deployment often, you will probably want to automate the process, rather than retype the jar (and maybe copy/cp) command each time. We show you how to do so using Ant, an Apache Software Foundation build tool that is also used in Chapter 9. Of course, you can also use any other tool you like, such as make, Perl, or a shell script or batch file, but Ant is the standard tool for this purpose in the Java and Tomcat communities, so it's probably good to know the rudiments of Ant.

Ant automates the running of other programs. More precisely, Ant can run non-Java programs, but benefits from being able to do a great deal of processing just by running Java classes. Because Ant is written in Java, it already has a JVM available, so running other Java functions (including a Java compiler) is pretty fast, as the JVM is already fired up. Ant also comes with a large library of built-in tasks for common operations, including dealing with TAR, JAR, ZIP, GZIP, and other file formats—usually without resorting to running external programs. That is, it contains OS portable Java classes that can read and write files in these and other formats, as well as copying files, compiling Java programs (including servlets), and much more.

Ant reads build files written in XML that are typically named build.xml[20] for its directions. An Ant build file contains one project definition and any ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required