ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Wallace <>
Subject Ant Incorrectly Determining Java Version
Date Wed, 26 Sep 2001 02:40:18 GMT
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.  Here's
the error message (and the source code that generated
it is below):

    [javac] Modern compiler is not available - using
classic compiler
    [javac] Compiling 342 source files to


/home/dev/jakarta-jetspeed/build/build.xml:175: Cannot
use classic compiler, as it is not available A common
solution is to set the environment variable JAVA_HOME
to your jdk directory."  

And BTW, yes I did set JAVA_HOME to no avail.

Okay, so I've traced this back to the
file and here's where it decides which Java version
you've got.  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?

"static {

        // Determine the Java version by looking at
available classes
        // java.lang.StrictMath was introduced in JDK
        // java.lang.ThreadLocal was introduced in JDK
        // java.lang.Void was introduced in JDK 1.1
        // Count up version until a
NoClassDefFoundError ends the try

        try {
            javaVersion = JAVA_1_0;
            javaVersion = JAVA_1_1;
            javaVersion = JAVA_1_2;
            javaVersion = JAVA_1_3;
            javaVersion = JAVA_1_4;
        } catch (ClassNotFoundException cnfe) {
            // swallow as we've hit the max class
version that
            // we have

Okay, now in CompilerAdapterFactory it uses this
information, but it does yet another wierd check. 
Again I'm wondering why not just accept the value of

" if ( compilerType.equalsIgnoreCase("modern") ||
compilerType.equalsIgnoreCase("javac1.3") ||
compilerType.equalsIgnoreCase("javac1.4")) {
                // does the modern compiler exist?
                try {
                } catch (ClassNotFoundException cnfe)
                    task.log("Modern compiler is not
available - using "
                            + "classic compiler",
                    return new Javac12();
                return new Javac13();"

Can someone provide insight as to why these checks are
so convoluted?  I imagine there's a logical reason, I
just don't know the history.  Does anyone know how I
can overcome this problem?


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

View raw message