ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan \"Rambius\" Ivanov" <>
Subject Re: classpath and simultaneous builds
Date Mon, 06 Feb 2006 04:35:10 GMT

--- Harshal Chavda <> wrote:

> Hello ant fraternity,
>                   I am a beginner in ant(version
> -1.6.3) 
First, I would suggest that you upgrade to the latest
version of Ant which is 1.6.5.

> and have 
> absolutely no knowledge of java(I can only write
> very simple java 
> programas in java).Can anyone please tell me "what
> is classpath and 
> how is it used"?

OK, classpaths specify a bunch of directories that
contain .class files and/or a list of .jar files.
Example, suppose you write an applicatrion that relies
of log4j[1] for doing its logging. You download log4j,
extract it and find log4j.jar. In order to use its
classes, Java must know where it should find it. So
you export a environment variable:

Pleaee note that it is possible that your application
relies on one classpath while compiling it, and a
slightly different classpath for running. For example,
you develop a JDBC application with oracle (and after
you are done with logging jar) you have to add the
oracle JDBC driver which is shipped in classes12.jar.
Usually, the JDBC driver is instanitiated via reflect
api like:

In this case you may not need classes12.jar to compile
the app, but you will need it while running the
application, so before you run it you do
(you still need log4j jar).

Usually, without a build tool like ant you would use
the second classpath as it is superset of the first
one. However, with ant you have much for flexibility
to reuse classpaths:

<path id="compile.cp">

<path id="runtime.cp">
  <path refid="compile.cp"/>
  <pathelement location="/path/to/classes12.jar"/>

<target name="compile">
  <javac ...>
    <classpath refid="compile.cp"/>

<target name="run">
  <java ...>
    <classpath refid="runtime.cp"/>

Note that runtime.cp path references compile.cp. This
provides a level of "classpath hygiene". For path-like
structures in Ant see [2].



Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message