开发者

Error installing Ant: ANT_HOME is set incorrectly

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\


It sounds like you have it setup right. What happens if you try something like this, which worked for me:

C:\>set ANT_HOME=C:\apache-ant-1.8.1

C:\>set JAVA_HOME=C:\jdk1.6.0_24

C:\>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

C:\>ant -version
Apache Ant version 1.8.1 compiled on April 30 2010

This also worked for me by setting up environment variables, like so:

Error installing Ant: ANT_HOME is set incorrectly


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 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.


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)


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


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.


Adding manually from Windows sometimes does not work...

To solve this, open command prompt and type these commands;

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

... then test:

C:\>ant -version 
Apache Ant(TM) version 1.9.2 compiled on JULY 8 2013


setting ANT_HOME from cmd worked for me somehow! C:>set ANT_HOME=C:\apache-ant-1.8.1


Close your command prompt after setting your environment variables and open another another one.


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.


I had the same issue and I was able to fix it by defining the %JAVA_HOME%\bin variable before defining the %ANT_HOME%\bin in my Path.

CORRECT: Path %JAVA_HOME%\bin;%ANT_HOME%\bin;........

WRONG: Path %ANT_HOME%\bin;%JAVA_HOME%\bin;.......


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.


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?


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


I ran into the same problem.

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

File->Properties->Unblock


Looks like there is an issue with apache-ant-1.8.3\bin\ant.bat.

Just comment the following lines in ant.bat and set the ANT_HOME environment variable and it should work.

if "%ANT_HOME%"=="" goto setDefaultAntHome

:stripAntHome
if not _%ANT_HOME:~-1%==_\ goto checkClasspath
set ANT_HOME=%ANT_HOME:~0,-1%
goto stripAntHome

:setDefaultAntHome
rem %~dp0 is expanded pathname of the current script under NT
set ANT_HOME=%~dp0..


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


Sounds somewhat stupid, but try restarting the computer if you haven't after the environment variable additions. I wasted a couple of hours not doing this.


Please try to set system variable of environment variables to the following:

1)ANT_HOME :: your ant folder(e.g. C:\ant\...)
2)JAVA_HOME :: your JDK path
3)Path:Till bin path( e.g.C:\jdk\bin;C:\ant\bin;)with semicolon

I tryed setting up ANT it was successful. Verify thro' command promt by typing ... ant -version you should get something like this: Apache Ant version 1.9.3 complied on December 10 2013


In my case it was a silly mistake, when you download the file I did not realize was that the directory, apache-ant-1.9.3-bin and copy directly to Program Files/apache-ant-1.9.3-bin. This gave me the error, I solved it by copying the apache-ant-1.9.3 folder is inside apache-ant-1.9.3-bin to Program Files/apache-ant-1.9.3 and perform the usual steps.


The trick is in avoiding spaces altogether!

Make sure that you don't add any unneeded spaces when adding to the PATH

PATH = %JAVA_HOME%\bin;%ANT_HOME%\bin


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.


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


If getting error like ant_home is set incorrectly or ant could not be located. please set ant_home Then follow following step which works for me.

1 . GO to computer properties (windows+pause Break)--> advance system setting

  1. System properties -->Advance---> environment variable

  2. DELETE ANT_HOME from User Variable

  3. ADD ANT_HOME in System variable and give the path of your apache ant folder as shown in figure.

Error installing Ant: ANT_HOME is set incorrectly

  1. ADD OR copy and paste as it is %ANT_HOME%\bin in the last of you path as shown in figure.

Error installing Ant: ANT_HOME is set incorrectly

  1. open cmd run ant -v that's all :)

Error installing Ant: ANT_HOME is set incorrectly


I set up the environment variables for Java and Ant correctly but it didnt work till I restarted System. Set Environment variables ANT_HOME, JAVA_HOME and restart system.


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.


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.


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


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 )


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜