‘ant’ is not recognized as an internal or external command, operable program or batch file.

This error comes when program is not able to find ant.bat i.e. Ant is not installed properly. Please visit How to install Ant.

Installing Apache Ant in Windows

Apache Ant is a Java-based build tool. To install ant, please follow the instructions.

1. Download Ant.

2. Unzip downloaded file.

3. Rename the unzipped directory to “ant”. You can choose another directory name, remember that name is not too long. A long name will create a problem in Win95, Win98 and WinMe.

On these systems, the script used to launch Ant will have problems if ANT_HOME is a long filename (i.e. a filename which is not of the format known as “8.3″). This is due to limitations in the OS’s handling of the "for" batch-file statement. It is recommended, therefore, that Ant be installed in a short, 8.3 path, such as C:\Ant.

4. Set ANT_HOME environment variable.

My Computer -> Advanced System Properties -> Environment Variable.
Now on the system variable click on New to add a new Environment Variable.

5. Update Path environment variable. e.g.(oldpath;%ANT_HOME%/bin;)

You don’t require to setup CLASSPATH because of the following reasons

  1. Do not ever set CLASSPATH. Ant does not need it, it only causes confusion and breaks things.
  2. If you ignore the previous rule, do not ever, ever, put quotes in the CLASSPATH, even if there is a space in a directory. This will break Ant, and it is not needed.
  3. If you ignore the first rule, do not ever, ever, have a trailing backslash in a CLASSPATH, as it breaks Ant’s ability to quote the string. Again, this is not needed for the correct operation of the CLASSPATH environment variable, even if a DOS directory is to be added to the path.
  4. You can stop Ant using the CLASSPATH environment variable by setting the -noclasspath option on the command line. This is an easy way to test for classpath-related problems.

To test if Ant is installed successfully, go to command prompt and type ant-h. It will show you help regarding ant usages.

Technology