0
votes

New here any just about anything else discussed on this site! Anyway, I'm trying to install ant on my machine but I'm getting an error from cmd:

'ant' is not recognized as an internal or external command, operable program or batch file

when running ant -version or ant -v. I'm using a Windows 7 machine (SP 1).

echo %PATH% command returns

C:\ProgramData\Oracle\Java\javapath;C:\Oracle11g\product\11.2.0\client_1\bin;C:\
Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Wi
ndows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPo
werShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Progra
m Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\I
ntel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN\bin;
C:\Users\hat10024\Desktop\Eclipse\apache-ant-1.9.4\bin;C:\Program Files\nodejs\;
C:\Users\HAT10032\AppData\Roaming\npm;C:\Users\HAT10032\AppData\Local\Android\sd
k\platform-tools;C:\Users\HAT10032\AppData\Local\Android\sdk\tools;C:\apache-ant
-1.9.5\bin\;C:\Users\HAT10032\AppData\Roaming\npm

Actual value in Path System Variable is:

C:\ProgramData\Oracle\Java\javapath;C:\Oracle11g\product\11.2.0\client_1\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN\bin;C:\Users\hat10024\Desktop\Eclipse\apache-ant-1.9.4\bin;C:\Program Files\nodejs\;C:\Users\HAT10032\AppData\Roaming\npm;C:\Users\HAT10032\AppData\Local\Android\sdk\platform-tools;C:\Users\HAT10032\AppData\Local\Android\sdk\tools;%ANT_HOME%\bin\

I know this is ugly and long and shouldn't look that way from other solutions I've been reading but any help would be greatly appreciated! Thanks!!

3
Just a thought, but maybe the directory for your ant installation is wrong? See if you can do dir C:\Users\hat10024\Desktop\Eclipse\apache-ant-1.9.4\bin. Also, I noticed that you've got 'hat10024' in that path, but 'C:\Users\HAT10032' on other paths. Maybe that's an error too? - David
Hi David! Thanks for the response! The command you suggested gives me an access denied response. As you probably figured out by now, this machine has multiple users in it. (Thus the other user you see there) - FRin
If that's the case, and the ant installation is in a different user's directory, then the "access denied" response makes sense. If your user account isn't able to see the contents of that directory, then setting the %PATH% to use that location won't help anything either. Get your own copy of ant, or have ant installed some place you can both get at it (Program Files maybe?). Installing ant is as easy as unpacking a zip file and, as you've observed, pointing some environment variables around. - David
Understood! So what would should I set the ANT_HOME variable to? Also, would it be under a User Variable or system variable? - FRin
I also notice that my ant/bin and ant/lib folders are empty. That shouldn't be, right? - FRin

3 Answers

3
votes

This can be done in 2 different ways:

1: From Command Prompt.

C:>set ANT_HOME=C:\Program Files\Ant Files\apache-ant-1.10.5

C:>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181

C:>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

C:> ant -version

Apache Ant(TM) version 1.10.5 compiled on July 10 2018

2: By setting environment variables.

Right click on This PC > Properties > Advanced system settings > Environment Variables > User variables > New > Variable name:**ANT_HOME & for **Variable value:**C:\Program Files\Ant Files\apache-ant-1.10.5 > **OK.

Now goto System variables to add bin path. System variables > double click on Path >New > C:\Program Files\Ant Files\apache-ant-1.10.5\bin >New >C:\Program Files\Java\jdk1.8.0_181\bin>OK.

Now lets check whether it is installed correctly or not.

goto Command Prompt > and type ant -version.

C:> ant -version

Apache Ant(TM) version 1.10.5 compiled on July 10 2018

That's it. Let me know if still getting any difficulties.

0
votes

Go to apache ant and download the zip file.

Extract to folder where Tomcat or other Apache is in.

Go to system porperties >> Environmen Variables

In user variables click new >> Add

  • Variable Name: ANT_HOME

  • Variable Value: C:\Program Files\Apache Software Foundation\apache-ant-1.9.6

In the path add

  • C:\Program Files\Apache Software Foundation\apache-ant-1.9.6\bin

If u want to add two path then

  • "C:\Program Files\Apache Software Foundation\apache-ant-1.9.6\bin"; "C:\Program Files\Apache Software Foundation\apache-maven-3.3.9\bin"

Then go to cmd and type ant -version

Should work fine.

0
votes

First, you have to download ANT. Here is the link https://ant.apache.org/bindownload.cgi.

Then extract your downloaded file in C:\Program Files\Ant Folder where Ant Folder is the folder name where I have extracted.

Now you have to set environment variables.
Right click on This PC > Properties > Advanced system settings > Environment Variables > User variables > New > Variable name:ANT_HOME & for Variable value:C:\Program Files\Ant Files\apache-ant-1.10.5 > OK.

Now goto System variables to add bin path. System variables > double click on Path >New > C:\Program Files\Ant Files\apache-ant-1.10.5\bin > OK.
Now lets check whether it is installed correctly or not. goto Command Prompt > and type ant -version.
That's it. Let me know if still getting any difficulties.