‘ant’ is not recognized as an internal or external command

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

I have the same issue as this user: ant - not recognized as an internal

however unfortunately none of the solutions have worked for me in that post or any other. I've also looked at other commands not recognized and specifically adding a path variable. The procedure I am using is as follows:

Extract to a desired installation directory, e.g. C:\apache-ant Create an ANT_HOME environment variable`  Open System Properties -> Advanced -> Environment Variables Create a new system variable     Variable name: ANT_HOME     Variable value: C:\apache-ant   Add %ANT_HOME%\bin directory to the PATH system variable  Open System Properties -> Advanced -> Environment Variables Under system variables, select PATH and append ;%ANT_HOME%\bin     e.g. %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%ANT_HOME%\bin  Verify that ANT is installed.  Open a new command window and type: C:\>ant -v` 

In my case the Variable value is C:\apache-ant\apache-ant-1.8.2.

My exact path variable is %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin;%ANT_HOME%\bin which doesn't have any spaces between semicolons.

However testing the ant installation does not work, the picture below is what I'm experiencing:

I have tried restarting on numerous occasions to no avail. I have run out of ideas, so if anyone has any any information would be helpful. Thanks!

EDIT

Posted results of dir:

回答1:

ANT_HOME is not being resolved. Change %ANT_HOME%\bin in the Path system environment variable to c:\apache-ant\apache-ant-1.8.2\bin.



回答2:

I had a similar issue, but the reason that %ANT_HOME% wasn't resolving is that I had added it as a USER variable, not a SYSTEM one. Sorted now, thanks to this post.



回答3:

create a script including the following; (replace the ant and jdk paths with whatever is correct for your machine)

set  PATH=%BASEPATH% set ANT_HOME=c:\tools\apache-ant-1.9-bin set JAVA_HOME=c:\tools\jdk7x64 set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH% 

run it in shell.



回答4:

When Environment variables are changed log off and log in again so that it will be applied.



回答5:

I downloaded ant (http://ant.apache.org/bindownload.cgi), unzipped to my C drive, and used the windows 'doskey' command:

doskey ant=C:\apache-ant-1.9.6\bin\ant.bat $* 

this will work as long as you use the same command console, to make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html



回答6:

Had the same problem. The solution is to add a \ at the end of %ANT_HOME%\bin so it became %ANT_HOME%\bin\

Worked for me. (Should be system var)



回答7:

Please follow these steps

  1. In User Variables

    Set VARIABLE NAME=ANT_HOME VARIABLE PATH =C:\Program Files\apache-ant-1.9.7

2.Edit User Variable PATH = %ANT_HOME%\bin

  1. Go to System Variables

    • Set Path =%ANT_HOME%\bin


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!