Ant not recognizing classpath

I can’t see why this Ant task fails:

<javac srcdir="src" destdir="bin" verbose="true" classpath="lib/*;${MyCommons.proj.path}/MyCommons.jar" />

My jars are all in lib, plus one external jar. When I mouse-over the classpath section eclipse shows all the jar files are recognized by this configuration.

On compile, I get 100 errors of can’t find this package or symbol (it’s not finding the jars).

[javac] Compiling 51 source files to C:MyProjectsMyCommonsbin
[javac] package org.joda.time does not exist
[javac] import org.joda.time.DateTime;
[javac]                     ^
[javac] package org.joda.time does not exist
[javac] import org.joda.time.DateTime;

I’ve tried every format of classpath I can find, classpathref’s, embedded , filesets, filelists, , etc. for about an hour.

Does anyone see an error?

Prior to this call I have a call to

<ant target="compile" dir="/some/other/project"/>

Removing this allowed the javac command to compile successfully.


you should try this (did not run myself but I think it works):

<path id="some.classpath">
    <fileset dir="lib">
        <include name="*.jar"/>
    <pathelement location="${MyCommons.proj.path}/MyCommons.jar"/>

and then

<javac srcdir="src" destdir="bin" verbose="true">
    <classpath refid="some.classpath"/>

If there are errors, put them in comments. I will correct it.

Leave a Reply

Your email address will not be published. Required fields are marked *