You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Phil Weighill-Smith <ph...@volantis.com> on 2004/10/12 12:19:57 UTC

JAVA_HOME, JAVACMD, javac and junit

Firstly, apologies if this seems off list: the general point might be
better addressed to the user list, but I have an issue with the "javac"
task's default value for the "executable" attribute and the "junit"
task's default value for the "jvm" attribute that probably relates
better to this list.

I've been looking at how to run Ant using 1.4 (we have Ant tasks that
use 1.4 specific features) while have it use a 1.3 compiler for the
"javac" task (and 1.3 runtime for "junit" test execution task). We need
to do this to ensure that our developed software is 1.3 compatible.

I *had* assumed that all I needed to do was set JAVACMD to point to the
1.4 java executable and have JAVA_HOME point to a 1.3 JDK. Sadly, this
doesn't appear to be the case.

I don't understand why the "javac" task requires the "executable"
attribute to be specified when attempting to do this (the documentation
says it defaults to the compiler for the JDK that Ant is run by...
surely this *should* default to the one found in JAVA_HOME instead).

I assume that I will have to explicitly use the "jvm" attribute on the
"junit" task invocation (again, it would seem sensible if this task used
JAVA_HOME to resolve the executable by default).

What do people think about the defaults for javac executable and junit
jvm?

Has anyone tried to do this sort of thing (different Ant and javac/junit
Javas)? If so, any hints or tips welcome!

Phil :n.

-- 
Phil Weighill-Smith <ph...@volantis.com>
Volantis Systems

Re: JAVA_HOME, JAVACMD, javac and junit

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 12 Oct 2004, Phil Weighill-Smith
<ph...@volantis.com> wrote:

> I don't understand why the "javac" task requires the "executable"
> attribute to be specified when attempting to do this (the
> documentation says it defaults to the compiler for the JDK that Ant
> is run by...  surely this *should* default to the one found in
> JAVA_HOME instead).

Ant and its developers seem to disagree with your "surely" 8-)

JAVA_HOME is really only used to locate the java executable (unless
you specify JAVACMD) and tools.jar (and even this won't use it anymore
with Ant 1.6.x).  It's just an environment variable with no special
meaning once Ant has started.  To Ant, environment variables become
irrelevant once we are in the pure Java part of it - and rightly so
since not all OSes support them and reading them is a pain pre JDK
1.5.

On top of that, changing the way Ant works here would break the builds
of people who are happy with running Ant without setting JAVA_HOME at
all.

> What do people think about the defaults for javac executable and
> junit jvm?

They match what I would expect.

> Has anyone tried to do this sort of thing (different Ant and
> javac/junit Javas)? If so, any hints or tips welcome!

Yes, I've done what you described.  forked javac and forked junit with
jvm/executable specified.

You can simplify it in your case by reading the environment into
properties and using ${env.JAVA_HOME} to build the path to your
executables, but that's about it.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org