ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edoardo Vacchi <>
Subject Ant System Class Loader does not honor $CLASSPATH, honors $LOCALCLASSPATH
Date Tue, 26 Mar 2013 17:25:46 GMT
Hi to everybody on the list,

I am forwarding the question I've asked on stackoverflow
as I did not have any feedback in several days. I hope I will find an
answer here.

Thanks in advance


I am implementing an ant task as a wrapper for another class, which
loads other several classes using the system class loader. Now, the
task is in the same jar of these other classes, so I wonder why it is
not finding them, since the task *is* running

Please notice that my classes are in the `$CLASSPATH` env variable.
The problem will not occur if I `export LOCALCLASSPATH=$CLASSPATH`

Minimal example:

    <taskdef name="mytask" classname="my.package.MyTask"  />

    <target name="compile">
        <mytask />

you can easily see the problem here

    public class MyTask extends Task {
       public void execute() throws BuildException {
        try {
            ClassLoader cl = ClassLoader.getSystemClassLoader();

            // this will only print the ant jar file path
            for(URL url: ((URLClassLoader)cl).getURLs()){

            cl.loadClass("my.package.OtherClass"); // throws an exception

        } catch (Exception ex) {
            throw new BuildException(ex);


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

View raw message