Java – “Error running javac compiler” in Ant

antjava

I was trying to run an Ant script in Eclipse, but I am getting the below error:

BUILD FAILED

C:\Users\name\workspace\Client\build\Build_Local.xml:111: Error running C:\Program Files\Java\jdk1.6.0_45\jre\bin\javac compiler.

My java home is pointed to jdk and I edited the java path in windows>preferences>installed jre as well as in run>external tool>config>jre. Both locations are pointed to jdk. Also I am posting my build file(This is not the exact file, I have edited a lot before posting)

<?xml version="1.0"?>
<project name="projectName" default="main" basedir="C:\path\build">
<property name="LocalHome" value="C:\proName" />
<property name="home" value="${LocalHome}"/>
<property name="java.home" value="C:\Program Files \Java\jdk1.6.0_45"/>
<property name="CLIENT_JAR" value="client.jar"/>

<target name="main" description=": This is the default target.">
    <antcall target="name"/>
</target>

<target name="name">
    <javac failonerror="true" srcdir="${home}/source" destdir="path to class file"
           executable="${java.home}\bin\javac" fork="true"  debug="on" encoding="UTF-8"
           source="1.6" target="1.6" bootclasspath="${java.home}/jre/lib/rt.jar"
           classpath=""/>
</project>

See here I mentioned the javac path to "C:\Program Files \Java\jdk1.6.0_45\bin\javac". Then why does Ant choose javac from C:\Program Files\Java\jdk1.6.0_45\jre\bin\javac (see the build error)

Best Answer

It worked when I directly used java home path(C:\Program Files\Java\jdk1.6.0_45) in place of java.home