ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Ant Incorrectly Determining Java Version
Date Wed, 26 Sep 2001 07:58:39 GMT
On Tue, 25 Sep 2001, Will Wallace <willscottwallace@yahoo.com> wrote:

> I'm running into problems compiling a project using
> JDK1.3.1 on Debian Linux and I think its because Ant
> doesn't properly recognize the Java version.

First thing I'd check is whether you are really running the Java VM
you want to run.  The "Modern compiler is not available" message will
show up in one of the following cases (and I think I've covered all of
them):

*) You explicitly set build.compiler to modern but you are not running
   a JVM >= 1.3 - some Linux distributions install more than one VM,
   some ship with Kaffee, what does "java -version" say?

*) You run a 1.3 VM, but tools.jar is not in your CLASSPATH - if
   JAVA_HOME is set correctly, this cannot happen.  Furthermore, Ant
   wouldn't find the "classic" compiler either, so this is probably
   the case here.

Where does JAVA_HOME point to?  Does any other source set JAVA_HOME
that overrides your setting?  Do you "export" JAVA_HOME?  Does
${JAVA_HOME}/lib/tools.jar exist?

Did you install Ant yourself or are you using a prebuilt package like
an RPM?

> One question I have is why does it do so in such a round about way
> -- why not just go with the java.version property?

The format of java.version is not really defined, different vendors
may choose different formats, so using reflections looks like the most
portable way.

> Okay, now in CompilerAdapterFactory it uses this
> information, but it does yet another wierd check. 

You can specifically ask Ant to use a different compiler than your
default by setting the build.compiler property.  

In JDK 1.3 you have the choice between the "classic" compiler and the
"modern" compiler as both are part of tools.jar.  Both implementations
from Sun have bugs, but they have different sets of bugs, so there may
be a very good reason to not use the "modern" implementation.

Now for the "wierd check" (I guess you are talking about the try catch
block 8-).  I've been the one putting it into the code long ago, and I
vaguely remember that I had some pre-release of IBM's JDK 1.3 for
Linux that did not contain com.sun.tools.javac.Main, so I implemented
the fallback.

Stefan

Mime
View raw message