ant is not recognized as an internal or external c

2019-07-14 03:28发布

问题:

  • I am running Windows XP Professional Version 5.1 with service pack 3
  • I have downloaded the JDK 1.6.0_24-b07 and have tested that it works
  • I downloaded apache ant .zip and installed it to C:\ant
  • I have set the path to ;%ANT_HOME%\bin
  • I have set the user variable name to ANT_HOME
  • I have set the user variable value to C:\ant\apache-ant-1.8.2

I have tried the 8.3 format, I have tried everything and I can't get it ant to work. Any advice?

Thanks in advance

回答1:

I just got to know that there should not be any space between the semicolon and the path we specify. I have been breaking my head how the hell does this happen despite making sure everything is right, let me illustrate this in better way:

ant_home=A:\apache-ant-1.8.2

path=someotherpath1;someotherpath2;A:\apache-ant-1.8.2\bin

Make sure there is no space between the semi colon and the path name.

And we think machines are perfect!!. This sounds stupid I know but it worked for me.

Cheers!!!



回答2:

Can run this command and put the output here?

echo %PATH%

Seems that Windows is not taking the right path and it's impossible for him to find the ant executable.



回答3:

I had the same problem, all variables configured but the "ant" command won't work. When printing the path (with echo %path%) , I had this result :

;C:\Program Files\jdk1.6.0.31\bin;%ANT_HOME%\bin;

Then I restarted the computer, and somehow this validated the ANT_HOME variable, so now it is working.



回答4:

  1. Recheck your settings, what's the output of => C:\> set, C:\>java -version ?
  2. Try to set your ant environment via batchfile - that's what i prefer for windows machines - and see
    if it works that way, f.e.

@ echo off

set ANT_ARGS=-lib C:\ant\extralibs
set ANT_HOME=C:\ant
set ANT_OPTS=-Xmx1024m
set JAVA_HOME=C:\JDK\1.6.0_24
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%;C:\cvsnt

: DEFAULT
call ant -f %1

: DEBUG
:call ant -debug -f %1

: XML LOGGER
:call ant -logger org.apache.tools.ant.XmlLogger -f %1

: Performance Monitoring
:call ant -listener ise.antelope.common.AntPerformanceListener -f %1

: Mail Logger
:call ant -logger org.apache.tools.ant.listener.MailLogger -DMailLogger.malhost=... -DMailLogger.from=BuildServer -DMailLogger.failure.to=... DMailLogger.success.to=... -f %1

pause


Some advantages of starting ant like that :

  • ANT_ARGS is a special environment variable. Its content is automatically added to the invocation of ant.
  • you may use your own ant settings on a machine where you have no admin rights
  • using a separate folder for your ant addon libs and load via -lib option keeps your ant installation clean and avoids polluting the %ANT_HOME%/lib folder


标签: ant