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条回答
祖国的老花朵
2楼-- · 2019-01-03 07:02

I had the same problem. If you check for a bin folder in your apache-ant-1.9.4 folder, you may find it doesn't exist.

This was the case for me, and I fixed the issue by simply downloading ant again and setting ANT_HOME,JAVA_HOME and PATH from cmd

All you need to do is this; you don't need to waste time trying to change and re-change your env; just try downloading it again.

查看更多
叛逆
3楼-- · 2019-01-03 07:04

To set or install ANT just add the address of your apache-ant into your PATH variables next to your installed jdk file, as show below

PATH Variables

C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program Files\apache-ant-1.9.6\bin

I hope this will help you guys! enjoy

查看更多
Summer. ? 凉城
4楼-- · 2019-01-03 07:05

I had the exact same problem and came across your post.

I figured out my problem was that somehow I did not have a lib directory in my ANT_HOME folder. It looks like the script looks specifically for ant.jar. I unzipped the apache ant zip again and everything worked great.

The error message:

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

for not having an ANT_HOME/lib directory was definitely misleading.

查看更多
可以哭但决不认输i
5楼-- · 2019-01-03 07:05

Try setting your ANT_HOME like below.it worked for me

ANT_HOME-----C:\apache-ant-1.8.4-bin\apache-ant-1.8.4

查看更多
Lonely孤独者°
6楼-- · 2019-01-03 07:05

For me loading the *.zip version helped. It seams it contains different data.

查看更多
劫难
7楼-- · 2019-01-03 07:05

If you set through MyComputer-->Environment variables it will work absolutely fine..

The same thing was happening to me when I was trying to do that through command prompt. It was an issue... but I figured out the problem... problem were the spaces

PATH = %PATH%;%ANT_HOME%\bin

remove the spaces from the above command it might work.

 PATH=%PATH%;%ANT_HOME%\bin
查看更多
登录 后发表回答