unable to find a javac compiler
I have a similar problem using Ant 1.6 on Windows.
This is unfortunately not a solution to your question.
I have a similar problem to yours so when you find out the answer I'd like to know what it is!
(I also tried the kludgey fix of copying tools.jar to %ANT_HOME%\lib but that didn't work.)
John (September 26th 2004)
----
The command I was using was 'ant doc', within a directory containing a build.xml file.
In the original ant.bat, the following statement was being used:
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -lib "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
Maybe the setting of classpath by
-classpath "%ANT_HOME%\lib\ant-launcher.jar"
was the problem.
I modified ant.bat to be as simple as possible. This resulted in a statement close to the manual-recommended minimal statement:-
java -Dant.home=c:\ant org.apache.tools.ant.launch.Launcher
When I ran this, at least I didn't get a NullPointerException error as the Launcher and Main were found and ran OK.
My environment variables are
%ANT_HOME%\lib\ant.jar;%ANT_HOME%\lib\ant-launcher.jar included in CLASSPATH
%ANT_HOME%\bin included in PATH]
----
However, now when build.xml gets to the property
<javac srcdir="${src}"
destdir="${build}"
excludes="**/*.java.*"
/>
Then this error is shown:-
init:
prepare:
compile:
[javac] Compiling 3 source files to C:\JimDemo\Pets02\build
BUILD FAILED
c:\JimDemo\pets02\build.xml:30: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
----
The main statement in the ant.bat file is :-
"%_JAVACMD%" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
If I specify classpath after Launcher in the above statement,
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -lib "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
in order to get
%JAVA_HOME%\bin on the classpath, then I get a NullPointerException error due to not being able to find Launcher.
I get the same error (NullPointerException) if
-lib %JAVA_HOME%\bin is placed after Launcher in the above statement instead of
-lib "%CLASSPATH%.
----