“ant”不被视为内部或外部命令

时间:2022-09-15 23:09:30

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

我和这个用户有相同的问题:ant -不被认为是内部的。

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.

在我的例子中,变量值是C:\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.

我的确切路径变量是%SystemRoot%\system32;%SystemRoot% SystemRoot%;%JAVA_HOME%\bin;%SystemRoot%\ Wbem;

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

然而,测试ant安装不起作用,下面的图片是我正在经历的:

“ant”不被视为内部或外部命令

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:

dir公布结果:

“ant”不被视为内部或外部命令

7 个解决方案

#1


39  

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.

ANT_HOME没有得到解决。将路径系统环境变量中的%ANT_HOME%\bin更改为c:\apache-ant -1.8.2\bin。

#2


11  

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.

我有一个类似的问题,但是%ANT_HOME%没有解决的原因是我将它作为一个用户变量添加,而不是系统变量。多亏了这篇文章,现在已经排好序了。

#3


6  

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

创建包含以下内容的脚本;(用正确的机器路径替换ant和jdk路径)

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.

在shell运行它。

#4


3  

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

当环境变量被更改时,注销并再次登录,以便应用它。

#5


3  

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

我下载了ant (http://ant.apache.org/bindownload.cgi),解压缩到C驱动器,并使用windows的“doskey”命令:

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

只要您使用相同的命令控制台,这将会起作用,使其成为永久的更困难:http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html。

#6


1  

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

有同样的问题。解决方案是在%ANT_HOME%\bin的末尾添加一个\,这样它就变成%ANT_HOME%\bin\

Worked for me. (Should be system var)

为我工作。(应该是系统变量)

#7


0  

Please follow these steps

请遵循以下步骤

  1. In User Variables

    在用户变量

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

    设置变量名=ANT_HOME变量路径=C:\程序文件\apache-ant-1.9.7

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

2。编辑用户变量路径= %ANT_HOME%\bin

  1. Go to System Variables

    去系统变量

    • Set Path =%ANT_HOME%\bin
    • 设置路径ANT_HOME = % % \ bin

#1


39  

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.

ANT_HOME没有得到解决。将路径系统环境变量中的%ANT_HOME%\bin更改为c:\apache-ant -1.8.2\bin。

#2


11  

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.

我有一个类似的问题,但是%ANT_HOME%没有解决的原因是我将它作为一个用户变量添加,而不是系统变量。多亏了这篇文章,现在已经排好序了。

#3


6  

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

创建包含以下内容的脚本;(用正确的机器路径替换ant和jdk路径)

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.

在shell运行它。

#4


3  

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

当环境变量被更改时,注销并再次登录,以便应用它。

#5


3  

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

我下载了ant (http://ant.apache.org/bindownload.cgi),解压缩到C驱动器,并使用windows的“doskey”命令:

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

只要您使用相同的命令控制台,这将会起作用,使其成为永久的更困难:http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html。

#6


1  

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

有同样的问题。解决方案是在%ANT_HOME%\bin的末尾添加一个\,这样它就变成%ANT_HOME%\bin\

Worked for me. (Should be system var)

为我工作。(应该是系统变量)

#7


0  

Please follow these steps

请遵循以下步骤

  1. In User Variables

    在用户变量

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

    设置变量名=ANT_HOME变量路径=C:\程序文件\apache-ant-1.9.7

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

2。编辑用户变量路径= %ANT_HOME%\bin

  1. Go to System Variables

    去系统变量

    • Set Path =%ANT_HOME%\bin
    • 设置路径ANT_HOME = % % \ bin