Ant - Classpath
Table of Contents
About
Classpath in a Ant Context
Articles Related
Element
The classpath element is defined in and have 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. <note tip>PATH attribute use also “:” and “;” as separator characters.</note>
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 | <note warning>To Avoid</note> All Java applications |
5 | in the <classpath> element | <note tip>Preferred option</note> 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