Error installing Ant: ANT_HOME is set incorrectly

2019-01-03 06:56发布

I read all the possible solutions but the none worked. I downloaded the ant and put it in C:\ant (so I have C:\ant\bin)

On Windows 7 under System variables I have variable called ANT_HOME with value

C:\ant

and variable called PATH with value

%ANT_HOME%\bin

And when I try in cmd (Command Prompt)

ant -version

I get

ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.

Also, if I try

echo %ANT_HOME%

I get

C:\ant

I tried PATH = %PATH%;%ANT_HOME%\bin but the same situation. Anyone?

EDIT:

Variables are (name - value):

ANT_HOME - C:\ant
CLASSPATH - .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
ComSpec - %SystemRoot%\system32\cmd.exe
FP_NO_HOST_CHECK - NO
JAVA_HOME - C:\Program Files\Java\jdk1.6.0_23
NUMBER_OF_PROCESSORS - 2
OS - Windows_NT
PATH - %ANT_HOME%\bin;%JAVA_HOME%\bin
PATHEXT - .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE - x86
PROCESSOR_IDENTIFIER - x86 Family 6 Model 15 Stepping 6, GenuineIntel
PROCESSOR_LEVEL - 6
PROCESSOR_REVISION - 0f06
PSModulePath - %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
QTJAVA - C:\Program Files\Java\jre6\lib\ext\QTJava.zip
TEMP - %SystemRoot%\TEMP
TMP - %SystemRoot%\TEMP
USERNAME - SYSTEM
windir - %SystemRoot%
XNAGSShared - C:\Program Files\Common Files\Microsoft Shared\XNA\
XNAGSv4 - C:\Program Files\Microsoft XNA\XNA Game Studio\v4.0\

标签: java ant
30条回答
Viruses.
2楼-- · 2019-01-03 07:11

Fix all the environment variables to correct location ANT_HOME, JAVA_HOME, PATH. Close the command prompt and open a new command window. Try running 'ant' command. It worked for me.

To test it : check the versions of JAVA and ANT.

C:> java -version
C:> ant -version

If its showing versions then other commands will also work.

查看更多
放我归山
3楼-- · 2019-01-03 07:12

Installing ANT gave me such hard time that I decided to reply to this thread as soon as I get it right.

I was getting the 'ANT_HOME is set incorrectly...'

I tried everything on this thread (almost) like %ANT_HOME%\bin and swapping the JAVA_HOME and ANT_HOME position on PATH variable, setting System variables than User variable etc. Nothing worked.

I downloaded the source distribution and it had no bin folder in it. So I deleted it, downloaded the binary version, unzipped it and set the ANT_HOME to C:\apache-ant-1.7.0 and %ANT_HOME%\bin to PATH under User variable.

It worked for me.

查看更多
唯我独甜
4楼-- · 2019-01-03 07:13

My problem has solved in windows xp, Steps are here (this is my setting change as per your installation):

  1. Set ANT_HOME to E:\Software\apache-ant-1.8.4
  2. add in Path %ANT_HOME%\bin;
  3. open command prompt and run command ant (you will see out put from ant)
查看更多
\"骚年 ilove
5楼-- · 2019-01-03 07:13

I had been facing the problem : here is my fix that got the ant working.

  1. dowload the proper file

    Go to

    http://archive.apache.org/dist/ant/binaries/

    and download the file "apache-ant-1.8.2-bin.zip"

  2. Set the following variables in System Environment Variable:

     set ANT_HOME=C:\apache-ant-1.8.2
     set JAVA_HOME=C:\jdk1.7.0_25
     set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;
    

Thank You.

查看更多
放荡不羁爱自由
6楼-- · 2019-01-03 07:13

Easy solution:

Use WinAnt installer for Windows. This installation of Ant will automatically install Ant into the C:\Program Files\WinAnt path by default. It also sets up your ANT_HOME and PATH variables to point at the new installation.

Manuall installation:

  • Download a .zip binary distribution from the ANT Binary Page.
  • Save the .zip file to a temporary location on your hard-disk (such as the desktop)
  • Expand the contents the folder inside of the .zip file into a directory on your hard drive (i.e. C:\dev\ant)
  • Go to your "System" Control Panel. In Vista, click the "Change Settings" button under the "Computer name, domain, and workgroup" heading.
  • On the "Advanced" tab, click the button at the bottom labeled "Environment Variables"
  • At the top of the screen, add a new User variable. The name should be ANT_HOME, and the value should be the path your zip file was extracted to. (i.e. ANT_HOME = C:\dev\ant)
  • Add your java JDK Path to the user variables as well. The name should be JAVA_HOME and the value should be the path to the JDK software on your hard-drive. (i.e. JAVA_HOME = C:\Program Files\java\jdk1.8.0_xx)
  • If there is already a PATH variable, edit it and add to it. Otherwise, create one more variable named PATH, and add to it ;%ANT_HOME%\bin

After installing Ant open the command prompt and type ant -v which will print the ant version which means you've successfully configured ant in your windows machine. Some windows may require a restart after setting the enviroment variables.

Source: AntOnWindows

查看更多
Rolldiameter
7楼-- · 2019-01-03 07:16

On Windows 7 you must run CMD as Adminitrator! When you just click Start and type to search box cmd then Java and ant both not recognized.

查看更多
登录 后发表回答