ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Wallace <>
Subject Re: Ant Incorrectly Determining Java Version
Date Wed, 26 Sep 2001 21:14:16 GMT
Hi Srinivas, Conor and Stefan,

Thanks a bazillion for your quick, thorough and
gracious responses.  With your help I was able to
successfully build Jetspeed and Ant.  In the interest
of saving you further trouble and improving the
self-documentation of Ant I want to suggest a change
in the error message text that would have given me the
clue I needed to fix it without having to bother

The key to it was the problem that Stefan described:
--- Stefan Bodewig <> wrote:
> *) You run a 1.3 VM, but tools.jar is not in your
>    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?

Okay the line above was the key because it told me the
exact condition that Ant was unable to satisfy and
enabled me to correct the JAVA_HOME.  To more
experienced people this is probably a no brainer, but 
for the sake of newbies to do their own
trouble-shooting, a bit more explicitness would help.

Currenty the error message says:

> "compile:
>     [javac] Modern compiler is not available - using
> classic compiler
> Cannot
> use classic compiler, as it is not available A
> solution is to set the environment variable
> to your jdk directory."

What would have helped would be adding the phrase
"cannot locate ${JAVA_HOME}/lib/tools.jar" to the "is
not available" in the messages above.  So it might
read in some fashion like: 

"Modern compiler not found - cannot locate
(com.sun.blah.blah classname) in 
${JAVA_HOME}/lib/tools.jar.  Using classic compiler."
"Cannot use classic compiler - cannot locate (whatever
the com.sun.blah.blah classname is) at
${JAVA_HOME}/lib/tools.jar. A common
solution is to set the environment variable JAVA_HOME
to your jdk directory so that the /lib/tools.jar file
is accessible."

Alternatively it strikes me that since it failed both
checks Ant could "realize" that the problem was likely
that it could not reach the /lib/tools.jar and provide
a case of an error message just for that eventuality.

Anyway, you get my idea? I'm not stuck on specifics,
just trying to convey my basic idea.  The key was that
I thought I did have the JAVA_HOME property exported
properly because other programs worked, but when I saw
that Ant's criteria was being able to access
/lib/tools.jar I was able to see that I needed to
change it.

Thanks also Stefan for explaining why Ant checks the
Java version in the way that it does and for not
taking offense when I said it seemed kind of
roundabout and wierd to me. ;-)  Your explanation
makes perfect sense.

Thanks so much!


> > 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,
> so I implemented
> the fallback.
> Stefan

Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.

View raw message