无法验证ANT 1.9.7设置



我刚刚在一台运行Windows 10的新电脑上安装了Java+Ant,当测试"Java-version"返回预期结果时,尝试"Ant-version"返回几个错误消息:

C:>ant -version                                                                                                           
C:>/*                                                                                                                     
'/*' is not recognized as an internal or external command,                                                                 
operable program or batch file.                                                                                            
C:>Licensed to the Apache Software Foundation (ASF) under one or more                                                     
'Licensed' is not recognized as an internal or external command,                                                           
operable program or batch file.                                                                                            
C:>contributor license agreements.  See the NOTICE file distributed with                                                  
'contributor' is not recognized as an internal or external command,                                                        
operable program or batch file.                                                                                            
C:>this work for additional information regarding copyright ownership.                                                    
'this' is not recognized as an internal or external command,                                                               
operable program or batch file.                                                                                            
C:>The ASF licenses this file to You under the Apache License, Version 2.0                                                
'The' is not recognized as an internal or external command,                                                                
operable program or batch file.                                                                                            
you was unexpected at this time.                                                                                           
C:>   (the "License"); you may not use this file except in compliance with

这种情况发生在最新的1.9.7版本中,但我也尝试了1.9.6,并在这台电脑上获得了相同的结果。我已经配置了以下环境变量集:

ANT_HOME=C:PROGRA~2ApacheAnt-1.9.7
JAVA_HOME=C:PROGRA~1Javajdk1.8.0_73
PATH=%SystemRoot%;%SystemRoot%system32;%JAVA_HOME%bin;%ANT_HOME%bin;

在谷歌上搜索任何错误消息行都不会检索到任何有趣的内容。这也不是PATH问题,因为Ant确实返回了错误,我也尝试直接从"bin"文件夹调用该命令。。。

睡了一个好觉后,我想调查%PATHEXT%中定义的扩展执行顺序。

不知怎么的,安装程序一定已经从更改了它

PATHEXT=.COM;.EXE;.BAT;.CMD;

PATHEXT=.EXE;.CMD;.COM;.BAT;

重置%PATHEXT%的原始订单后,我的问题得到了解决。。。正确的顺序如下:

PATHEXT=.COM;.EXE;.BAT;.CMD;

bin文件夹中有两个"ant"可执行文件,一个是".bat",一个".cmd"。键入

ant.bat -version

产生预期的输出。键入

ant.cmd -version

产生了我在问题中报告的错误。因此,通过在查看".cmd"之前处理".bat"来更改扩展执行顺序…

根据ANT文档,尝试以下

您可以打开一个新的shell并键入ant来检查基本安装。你应该得到这样的信息

Buildfile: build.xml does not exist!
Build failed

所以蚂蚁是有效的。之所以出现此消息,是因为您需要为项目编写一个单独的构建文件。

对于蚂蚁版本,你应该得到类似的输出

  Apache Ant(TM) version 1.9.2 compiled on July 8 2013

如果这不起作用,请确保环境变量设置正确。他们必须下定决心:

 required: %ANT_HOME%binant.bat
 optional: %JAVA_HOME%binjava.exe
 required: %PATH%=...maybe-other-entries...;%ANT_HOME%bin;...maybe-other-entries...

有关更多信息,请点击

谢谢,Murali