ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <>
Subject Re: jdks and ant
Date Wed, 06 Dec 2000 22:35:03 GMT
Hello Mathew,

Create a batch file to be used for each JDK/SDK which sets the necessary
environment variables and then calls ant.bat.  For instance:


@echo off
setlocal (for NT only)
rem Ant wrapper for a JDK 1.1
set ANT_HOME=c:\ant
set JAVA_HOME=c:\jdk11
set JAVACMD=%JAVA_HOME%\bin\java.exe
rem Set to third-party stuff, not anything a target in the build.
rem Call ant script
call "%ANT_HOME%\bin\ant" %1 %2 %3 %4 %5 %6 %7 %8 %9  (Windows 9x)
call "%ANT_HOME%\bin\ant" %*  (Windows NT)
endlocal (for NT only)

Just copy this file with a name appropriate for each JVM version, edit the

If you wanted to be a bit fancier, you could modify the above to use a
single script and assume the first argument refers to the JVM version. 
Save and set the value of JAVA_HOME and CLASSPATH based on that and shift
to remove the argument.

When setting your CLASSPATH before running Ant, make sure it doesn't
include anything that is part of a build target in Ant.  Specifically, if
you add a .jar file to your CLASSPATH before starting Ant and the build
tries to replace that .jar file you will have problems on Windows because
the JVM holds the file open and won't let you replace it.  

Because Ant is so capable of dealing with the CLASSPATH itself (like
making it easy to add all the .jar files in a directory to the CLASSPATH),
you may be better off unsetting the CLASSPATH in your batch file and
defining it in Ant.

-Bill Burton

Mathew Mathew wrote:
> Hi,
>  I am new to using ANT. I like what I've seen so far, but I have some basic
> questions.
> My environment is pretty messy out of necessity, in that I have three
> versions of the jdk installed
> 1.jdk1.1
> 2.jdk1.2.2
> 3.jdk1.3
>  I control my builds by writing scripts that call the required jdks commands
> with the paths hardcoded.
>  For example if I wanted to compile with jdk1.3, my script would read
> something like
> c:/jdk1.3/bin/javac -classpath ""  ......
>  How do I control all these variables with ant and ensure that I am building
> with the right compiler.
> Thanks
> Matew

View raw message