O'Reilly logo

Ant: The Definitive Guide by Jesse Tilly, Eric M. Burke

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

Configuration

Once Ant is installed properly, it requires very little additional configuration. Provided the ant.bat batch file (or ant shell script) is installed in a directory that is included in your system path, you should be able to run Ant from any command prompt.

You do not technically have to use the provided ant or ant.bat script to run Ant. You can run Ant manually, as long as the following items are configured:[11]

  • The system CLASSPATH includes ant.jar and any JAXP-compliant XML parser.

  • For JDK 1.1, classes.zip must be added to the CLASSPATH. For Java 2, tools.jar must be added. This is necessary for tasks like javac.

  • Many tasks require that the ant.home Java system property be set to the Ant installation directory. This is accomplished by launching the JVM with the -D flag, as shown shortly.

  • JAR files for optional tasks must be added to the CLASSPATH.

Provided that these items are all set properly, you can use the following command to invoke Ant:[12]

java -Dant.home=pathToAnt org.apache.tools.ant.Main

Tip

Understanding how to set up and run Ant manually might be useful if you are making customizations to Ant and wish to run it using your IDE’s debugger.

XML Issues

Early versions of Ant (prior to Version 1.4) include Sun’s Java API for XML Parsing (JAXP) Version 1.0. Ant Versions 1.4 and later ship with JAXP 1.1, as described in the next paragraph. JAXP is an API allowing Java programs to use XML parsers from different vendors in a portable way. The JAXP JAR files, jaxp.jar ...

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