I am getting the following error when I try to run an ant buildfile in eclipse:
BUILD FAILED
C:\mypath\myapp\BuildWar.xml:16: 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\jre7"
I located the jdk at C:\mypath\Java\jdk1.7.0_17\bin\javac.exe
I used the methods in this blog entry to create a system environmental variable in windows 7 called JAVA_HOME and mapped to C:\mypath\Java\jdk1.7.0_17\bin\javac.exe . When the error persisted, I restarted the computer, tried again, and got the same error. I then changed the mapping of JAVA_HOME to C:\mypath\Java\jdk1.7.0_17\bin\ and still got the same error.
Can anyone show me how to get past this error, so that I can run my ant build file in eclipse?
EDIT:
I am getting the same exact error message again today when I try to run the ant buildfile, even though JAVA_HOME is set as per the answers below, and even though the path variable now includes %JAVA_HOME%\bin . I have checked the values of these environmental variables in the windows control panel section for setting environmental variables, even though the eclipse console gives the above error message saying JAVA_HOME is set to a jre. Does anyone have any suggestions about how to fix this recurring problem?
SECOND EDIT:
Changing the Java Home in eclipse fixed this problem. The eclipse Java Home is separate from the windows Java Home.