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条回答
SAY GOODBYE
2楼-- · 2019-01-03 07:17

Ok my problem was solved through this thread. I'll just summarize what I did.

  1. Add the JAVA_HOME and ANT_HOME as system variables instead of user variables.
  2. Make sure that the JAVA_HOME is pointing towards your JDK directory and not the JRE directory. TOOLS.java is a part of JDK and not JRE.
查看更多
\"骚年 ilove
3楼-- · 2019-01-03 07:17

I ran into the same problem.

When you download the zip file make sure you unblock the zip.

File->Properties->Unblock

查看更多
Anthone
4楼-- · 2019-01-03 07:17

This is an update to other answers here: It appears that ant comes with Netbeans 8.1, but the developers of Netbeans have decided to move ant out of the Netbeans core or something. ( https://netbeans.org/bugzilla/show_bug.cgi?id=225753 ) see below for the new correct path. For my current version of netbeans 8.1 this is what I had to do to get ant to work from the command line: (Windows 10)

in system (not user) variables :

set JAVA_HOME to  C:\Program Files\Java\jdk1.8.0_73  (with your version number)

set ANT_HOME   to   C:\Program Files\NetBeans 8.1\extide\ant

add to PATH in system variables : C:\Program Files\NetBeans 8.1\extide\ant\bin

so this has 'bin'added to ant home. (ant Home is one dir higher)

Preferably set the path by browsing to it using the environment var editor of windows. It adds " " in the right way.

( I was trying to install Jfreechart which refers to using ant to install part of it. That was supposed to make it easier..... yeah... after figuering out and fixing the ant install )

查看更多
Animai°情兽
5楼-- · 2019-01-03 07:19

Somehow it appears to be very strange problem. Couple of guesses:

1) I hope you've downloaded ANT from here: http://apache.mirror.aussiehq.net.au//ant/binaries/apache-ant-1.8.2-bin.zip. If not, you can try that once.

2) I hope there is no security related issues that is preventing you to access ANT from command window, just to double check, copy the new ANT installation in some other directory, may be D:\MyFolder etc..

3) Is Java - version running properly? Or are you getting the similar kind of issue?

4) Also Go inside $ANT_HOME\bin folder through command prompt by typing cd C:\ant\bin and type $ant.bat.. what error you get?

查看更多
迷人小祖宗
6楼-- · 2019-01-03 07:20

I had same trouble a while ago I think I figured out the problem.

How : 1.Since I Set ANT_HOME(C:\ant\ant-1.8.2) in Path correctly I was confident about it. 2.I was planning to do "ant setup" and "ant apply. I opened path where I was planning to ant setup in command prompt next I tried setenv.bat...

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

Setenv.bat was setup something like this @echo off

set JAVA_HOME=C:/Program Files (x86)/Java/jdk1.6.0_18 set ANT_HOME=C:/Project/Setup_Binaries/JBoss_Ant_2012/ant-1.8.2 set HOS_LIB_PATH=

Rather it should've been C:\ant\ant-1.8.2 which was changing my ANT_HOME.

I edited setenv.bat to my ANT_HOME which I set in PATH then it worked fine.

查看更多
Fickle 薄情
7楼-- · 2019-01-03 07:22

I was facing the same issue. But the problem was that I had added ANT_HOME to user variables in Windows.

I removed it and added ANT_HOME to system variables. It works fine now.

查看更多
登录 后发表回答