Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 52697 invoked by uid 500); 26 Sep 2001 02:40:08 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 52688 invoked from network); 26 Sep 2001 02:40:08 -0000 Message-ID: <20010926024018.88525.qmail@web20806.mail.yahoo.com> Date: Tue, 25 Sep 2001 19:40:18 -0700 (PDT) From: Will Wallace Subject: Ant Incorrectly Determining Java Version To: ant-dev@jakarta.apache.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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): "compile: [javac] Modern compiler is not available - using classic compiler [javac] Compiling 342 source files to /home/dev/jakarta-jetspeed/bin/classes BUILD FAILED /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 Project.java 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 1.3 // java.lang.ThreadLocal was introduced in JDK 1.2 // java.lang.Void was introduced in JDK 1.1 // Count up version until a NoClassDefFoundError ends the try try { javaVersion = JAVA_1_0; Class.forName("java.lang.Void"); javaVersion = JAVA_1_1; Class.forName("java.lang.ThreadLocal"); javaVersion = JAVA_1_2; Class.forName("java.lang.StrictMath"); javaVersion = JAVA_1_3; Class.forName("java.lang.CharSequence"); 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 java.version? " if ( compilerType.equalsIgnoreCase("modern") || compilerType.equalsIgnoreCase("javac1.3") || compilerType.equalsIgnoreCase("javac1.4")) { // does the modern compiler exist? try { Class.forName("com.sun.tools.javac.Main"); } catch (ClassNotFoundException cnfe) { task.log("Modern compiler is not available - using " + "classic compiler", Project.MSG_WARN); 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? Will __________________________________________________ Do You Yahoo!? Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com