无法验证ANT 1.9.7设置

时间:2016-04-17 00:15:13

标签: java ant windows-10

我刚刚在运行Windows 10的新PC上安装了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并在此PC上获得了相同的结果。 我已配置以下环境变量集:

ANT_HOME=C:\PROGRA~2\Apache\Ant-1.9.7
JAVA_HOME=C:\PROGRA~1\Java\jdk1.8.0_73
PATH=%SystemRoot%;%SystemRoot%\system32;%JAVA_HOME%\bin;%ANT_HOME%\bin;

Google搜索任何错误消息行都不会检索任何有趣的内容。它不是PATH问题,因为Ant确实返回了错误,我尝试直接从" bin"文件夹以及......

2 个答案:

答案 0 :(得分:1)

经过一夜安眠后我会考虑调查%PATHEXT%中定义的扩展执行顺序。

某种程度上安装程序必须从

更改它
PATHEXT=.COM;.EXE;.BAT;.CMD;

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

重置%PATHEXT%之后它的原始订单我的问题已得到解决......请在下方更正订单:

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

有两个" ant" bin文件夹中的可执行文件a" .bat"和#34; .cmd"。打字

ant.bat -version

产生预期的输出。打字

ant.cmd -version

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

答案 1 :(得分:0)

根据ANT文档,请尝试以下

您可以通过打开新shell并键入ant来检查基本安装。你应该收到这样的消息

Buildfile: build.xml does not exist!
Build failed

所以Ant工作。此消息存在,因为您需要为项目编写单独的构建文件。

使用ant -version你应该得到像

这样的输出
  Apache Ant(TM) version 1.9.2 compiled on July 8 2013

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

 required: %ANT_HOME%\bin\ant.bat
 optional: %JAVA_HOME%\bin\java.exe
 required: %PATH%=...maybe-other-entries...;%ANT_HOME%\bin;...maybe-other-entries...

了解更多信息here

谢谢你, 穆拉利