ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Having a problem with the classpath passed to <javac> task
Date Mon, 04 Dec 2000 14:42:32 GMT
Jay Glanville <> wrote:

> I am trying to compile my source code to a target 1.1 VM.  The
> compilers I like to use are Jikes and javac 1.3.  My problem is that
> when I use the <javac> task in conjunction with a 1.3 runtime
> environment, the tools.jar file gets included in the classpath if
> I'm using the modern compiler, and tools.jar and rt.jar if I'm using
> the jikes compiler.  This is the major reason that I cannot use Ant
> in my build environment.

This is a known problem and you'll probably have attributes in <javac>
to suppress this behavior in Ant 1.3.

> Is there anything I can do to solve this problem (excluding having
> to use a <exec> task) ?

As a workaround, write your own implementation of Javac, a very simple
and untested idea:

public class MaJavac extends Javac {
    protected Path getCompileClasspath(boolean addRuntime) {
        return super.getCompileClasspath(false);

This will suppress rt.jar even when compiling with Jikes. You can copy
what Javac's getCompileClasspath does and omit the line


to get rid of tools.jar as well.

At the top of your buildfile say

<taskdef name="javac" classname="MyJavac" />

and you are done.

> While I'm on the subject of unwanted stuff in the classpath, is
> there any way that I can get rid of the ant libraries?  I know that
> there is very little chance of namespace collisions, or any other
> worries.  But it would be nice to simply have the following as an
> execution line: jikes -d F:\test\classes -classpath
> C:\jdk\1.1.8\lib\;F:\test\classes;F:\test\src

Yes, the second option above (omitting Path.systemClasspath) should do
that as well.

You could as well add options to (1) omit the runtime libraries and
(2) omit the CLASSPATH Ant has been invoked with to Javac, make the
modifications necessary to getCompileClasspath and contribute the
patch so you will see this feature in CVS sooner 8-).


View raw message