ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "david" <>
Subject Re: Problems understanding classpath and package
Date Sat, 29 Dec 2007 19:36:26 GMT
Hello Andrew, try ant -p to get a look at the Ant default environment. Packaging is part of
Java and not peculiar to Ant. A good tool to use when packaging and jars are a mystery is
Jarscan found at:

Insert the following Ant target snippet into your build.xml file and run: ant -p to make sure
the newly inserted target is available. If you are successful at this point then run:

ant showclasspath

<target name="showclasspath">
	<echo message="environment classpath: ${env.CLASSPATH}"/>
<!-- END SNIPPET -->

The returned results should show the default classpath according to your machines environment.

The above assumes some type of command line: Windows cmd, Linus bash terminal, Solaris korn
shell, Mac command-line OS X terminal.

You should also be able to perform the above using your favorite IDE: Eclipse, IDEA, Netbeans,

In the future to get better responses from the Ant community please initiate your email with
more information such as:

Ant version: 1.7.x
OS: Debian 3.1 (or Windows XP SP2 or similar)
JDK: 1.6.x
Source: snippets only (build.xml, etc.)
Logs: Ant logs, system logs, application logs (error messages, exceptions etc.)
Environment: system variable values, ant properties (ex: classpath) etc.

If you are fairly new to Ant then in all-likelihood you are fairly new to Java. Some good
resources follow:

HTH, David.

Andrew Connick wrote ..
> Hello
> I am fairly new to Ant. I am trying to use it to compile java, but I am
> having problems with 'package does not exist' I assume it's a classpath
> issue. Although I can find plenty of advice on how to set the classpath,
> I
> cannot understand what it should be.
> My directory structure is something like
> -  classes
>   - base
>     -
>   - forms
>     -
>   - build.xml
> - lib
> The first two lines of classes\forms\ are:
> package tags;
> import base.*;
> When I try to compile this with Ant, I get 'package does not exist'. My
> understanding of the documentation is that I should not need any classpath
> because it's the basedir. Also, if I run "ant -verbose" I see the following:
>     [javac] '-classpath'
>     [javac] 'C:\My Web Sites\CMS\V2\WEB-INF\classes;C:\Program Files\Apache
> Software.......
> If  I run javac from the command line, with directory set to "classes"
> it is
> fine.
> My classes\build.xml is:
> <project name="Compile all" default="jar" basedir=".">
>  <property name="jarfile" value="cms_v2.jar" />
>  <target name="delete">
>   <delete><fileset dir="." includes="**/*.class"/></delete>
>  </target>
>  <target name="compile" depends="delete">
>   <javac srcdir="base" destdir="." />
>   <javac srcdir="forms" destdir="." />
>  </target>
>  <target name="jar" depends="compile">
>   <jar basedir="." destfile="../lib/${jarfile}" includes="**/*.class" />
>  </target>
> </project>
> Regards
> Andrew Connick
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message