ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Boving <sebast...@cirquedigital.com>
Subject Re: Modern compiler not available
Date Wed, 05 Dec 2001 17:53:58 GMT
Nico,

Nico Seessle wrote:

> > Some question regarding this error message ("Modern compiler not
> > available"): How exactly does Ant determine no 'modern' compiler is
> > available? My compiler _is_ modern, and the error message and debugging
> > info don't provide me enough info to correct the problem.
>
> 1. If fork is set to true everything below is irrelevant...

it's not the case, but that could be a workaround indeed.

> 2. If the property "build.compiler" is not set, the "modern" Compiler is
> used if the Java-Version Ant detected is not 1.1 and not 1.2. Otherwise the
> "classic" compiler is used.

it could be he thinks he's got 1.1. or 1.2, but that would be strange since i
used very common Sun JDK 1.3.1_01 and 1.4.0b3 JDK's.

> 3. Ant does a lookup (using Class.forName("com.sun.tools.javac.Main")) to
> find the classes representing the modern compiler, if a
> ClassNotFoundException is thrown it will output "Modern compiler is not
> available - using classic compiler".
>
> That's all.

This is indeed the problem.

If my cmd.exe env var CLASSPATH includes tools.jar your program (see below)
does work correctly.
If my cmd.exe env var CLASSPATH does not include it i get  'Modern Compiler not
available'.

Logic.

If i run Ant with the CLASSPATH including tools.jar in my environment, it still
doesn't work.
However, if i add tools.jar in the 'classpath' attribute of the javac task, it
works. See below for the details.

So i have a solution (and could always do it with 'fork' as you mentionned).
I'm just surprised Ant is not using my environment CLASSPATH (or is not adding
$JAVA_HOME/lib/tools.jar by default himself). Also the debugging output did
show tools.jar was included in the project property 'java.class.path', but
still it doesn't seem to get passed on to the javac task.

This still looks weird to me, but i'm new to Ant so would want to suggest
anything. This might be the default behaviour, or i'm doing something else
wrong. I can provide more info in case this is relevant though.

thanks for the help,
Sebastien.

D:\temp\test>echo %JAVA_HOME%
d:\soft\win-ix86\jdk\1.3.1_01

D:\temp\test>set CLASSPATH=d:\soft\win-ix86\jdk\1.3.1_01\lib\tools.jar;.

D:\temp\test>javac CompTest.java

D:\temp\test>java CompTest

D:\temp\test>set CLASSPATH=.

D:\temp\test>java CompTest
Modern Compiler not available

D:\temp\test>set CLASSPATH=d:\soft\win-ix86\jdk\1.3.1_01\lib\tools.jar;.

D:\temp\test>type build-compile.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="test-compile" default="compile" basedir=".">

  <target name="compile">
    <javac srcdir="." destdir="." debug="on">
      <include name="*.java"/>
    </javac>
  </target>

</project>

D:\temp\test>ant -version
Ant version 1.4 compiled on September 3 2001
D:\temp\test>ant -f build-compile.xml
Buildfile: build-compile.xml

compile:

BUILD SUCCESSFUL

Total time: 0 seconds
D:\temp\test>
D:\temp\test>
D:\temp\test>rem Added classpath attribute in build-compile.xml
D:\temp\test>type build-compile.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="test-compile" default="compile" basedir=".">

  <target name="compile">
    <javac srcdir="." destdir="." debug="on"
           classpath="d:\soft\win-ix86\jdk\1.3.1_01\lib\tools.jar;.">
      <include name="*.java"/>
    </javac>
  </target>

</project>

D:\temp\test>ant -f build-compile.xml
Buildfile: build-compile.xml

compile:

BUILD SUCCESSFUL

Total time: 0 seconds


In the first 'ant' command (no classpath set inside the javac task), debugging
output shows:

Setting project property: java.class.path ->
d:\soft\win-ix86\jdk\1.3.1_01\lib\t
ools.jar;d:\soft\win-ix86\jakarta-ant-1.4\bin\\..\lib\jaxp.jar;d:\soft\win-ix86\

jakarta-ant-1.4\bin\\..\lib\crimson.jar;d:\soft\win-ix86\jakarta-ant-1.4\bin\\..

\lib\ant.jar;d:\soft\win-ix86\jdk\1.3.1_01\lib\tools.jar;.

Tools.jar is twice in there (once by Ant, once from my CLASSPATH env var).


>
>
> > I have this error on my Win2k box, with several versions of Ant, several
> > versions of JDK's, each time with a correct JAVA_HOME and a
> > lib/tools.jar in it.
>
> Hmm... looks good.
>
> Can you run this "program"
>
> public class CompTest {
>
>     public static void main(String[] args) {
>         try {
>             Class.forName("com.sun.tools.javac.Main");
>         } catch (ClassNotFoundException cnfe) {
>             System.out.println("Modern Compiler not available");
>         }
>     }
> }
>
> with the settings you posted to verifiy that it's really Ant heaving
> problems here?
>
> Nico
>
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>

Mime
View raw message