You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mathew Mathew <mm...@skillsoft.com> on 2000/12/06 21:51:24 UTC

jdks and ant

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



Re: jdks and ant

Posted by Bill Burton <bi...@progress.com>.
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:

ant11.bat:

@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.
set CLASSPATH=...
rem Call ant script
call "%ANT_HOME%\bin\ant" %1 %2 %3 %4 %5 %6 %7 %8 %9  (Windows 9x)
  or
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
value of JAVA_HOME and CLASSPATH.

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

RE: jdks and ant

Posted by Adam Murdoch <ad...@yahoo.com>.
Hi,

You have a few options.  Probably the simplest is to set the JAVA_HOME and
JAVACMD variables and use the supplied ant script.

set JAVA_HOME=c:/jdk1.3
set JAVACMD=%JAVA_HOME%/bin/java

The ant script was recently patched so that you don't have to set JAVACMD -
you might want to grab it out of CVS or a nightly build.

Some other options are to hack the supplied script, or write your own.


Adam

> -----Original Message-----
> From: Mathew Mathew [mailto:mmathew@skillsoft.com]
> Sent: Thursday, 7 December 2000 6:51 AM
> To: ant-user@jakarta.apache.org
> Subject: jdks and ant
>
>
> 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
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com