Table of Contents

About

Classpath in a Ant Context

Element

The classpath element is defined and has the scope of a task.

<classpath>
    <pathelement location="lib/helper.jar"/>
    <pathelement path="${classpath}"/>
</classpath>

where:

  • the location attribute refer to a single file or directory relative to the project's base directory (or an absolute filename)
  • the path attribute accepts colon- or semicolon-separated lists of locations. PATH attribute use also “:” and “;” as separator characters.

Library

Libraries can be added to Ant's classpath in any of the following way:

Priority Library Library Scope
1 in ANT_HOME/lib directory All Ant users and builds
2 in ${user.home}/.ant/lib (as of Ant 1.6) The command-line Ant
3 with the command line -lib parameter The command
4 in the CLASSPATH environment variable To Avoid All Java applications
5 in the <classpath> element Preferred option The task

Support

java.lang.ClassNotFoundException

To test for classpath-related problems, set the -noclasspath option. Ant will then stop using the CLASSPATH environment variable.

ant -noclasspath 

Documentation / Reference