'"java.exe"' is not recognized as an internal or external command,

You need to put the file java.exe in your PATH variable but the JRE in JAVA_HOME


If you look at the "ant.bat" file, you will see that it looks for the "java" command in the following way:

  1. If the %JAVACMD% environment variable is set, then it uses that.
  2. Otherwise, if the %JAVA_HOME% environment variable is set, it tries to use %JAVA_HOME%\bin\java.exe
  3. Otherwise, it tries to use java.exe; i.e. it will look on your %PATH%.

In your case, you have %JAVA_HOME% set ... but set to the Java installation's "bin" directory, not to the root of the installation. So the Ant.bat script looks in the wrong place for java.exe.

Just set %JAVA_HOME% correctly, and it should work.

JAVA_HOME C:\Program Files\Java\jdk1.7.0_06

As you can see from the above, you do not need to have the Java "bin" directory on your %PATH% for Ant to work, but it is a good idea to set it anyway. That way you can run the Java commands simply from the command line.

The setting of %CLASSPATH% is not relevant to this problem. Indeed, unless the build.xml file is broken, Ant will ignore your %CLASSPATH% environment variable.

Tags:

Java

Ant