Unable to find a javac compiler
by Abhijeet Kashnia
I faced this problem while writing an ant file in eclipse:
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.It is currently set to "C:\Program Files\Java\jre1.5.0_21"
The problem is that by default Eclipse uses some JRE and gives this error when I try to write a compile target which needs a JDK and not the JRE.
<target name="compile" description="Compile Java sources" >
<javac srcdir="${project.src}" destdir="${project.build}" >
<!--<classpath refid="${jdk.path}" />-->
</javac>
</target>
So, you either force the JAVA_HOME to point to the JDK and not the JRE, orthe solution in my case was to find out the JRE which is being used (it mentions that path)in the console window itself. Then, copy the tools.jar from the JDK/lib to the JRE/lib/ext/
And that fixed it.