How to set ANT_HOME with Windows?
Asked Answered
A

6

25

How can I easily set ANT_HOME under Windows? I added "D:\Installz\apache-ant-1.8.2\bin;" to my system environment variable PATH and I also created an ANT_HOME variable.

Acis answered 15/2, 2012 at 8:46 Comment(4)
If you have already set your ANT_HOME, what do you want us to explain?Mop
possible duplicate of ant - not recognized as an internalDermatology
This link will defiantly help you #5608164Noncompliance
Your ANT_HOME value is wrong. It should be D:\Installz\apache-ant-1.8.2; instead of D:\Installz\apache-ant-1.8.2\bin;Tetrapterous
Z
23

I expect you to be running on Windows (since you are using %). Simply add a new environment variable (Right-click on My Computer > Properties > Advanced > environment Variable) or using SET ANT_HOME=<path> using command line (in that cas, it will only be active on that command line).

Once set you should be able to verify its value by doing echo %ANT_HOME% in command line

The % sign around the variable indicates it is an environment variable.

For linux use the export ANT_HOME=<path> in command line or in your ~/.profile (persistent, require logout/login). Use echo $ANT_HOME for verification.

Zellazelle answered 15/2, 2012 at 9:2 Comment(2)
Another strong hint toward a Windows installation is the D:\path ^_^'Yunyunfei
Don't put a backslash after path or it won't work. The ant docs warn about this.Vanitavanity
T
51

In Windows 7 you can go to Control Panel\All Control Panel Items\System or right click on Computer and then to “Advance system setting”

  1. Choose Advanced Tab
  2. Click "Environment Variables" button
  3. In System Variables, click "New" button
  4. Set Variable Name: ANT_HOME and value as {directoryPath}\apache-ant-1.8.2 (Ex: D:\Installz\apache-ant-1.8.2)
  5. Click OK
  6. Either click again on New button if you do not have ‘Path’ Variable in there

    OR

    Select it and edit by adding the value : %ANT_HOME%\bin;

  7. Click OK
  8. To check if ANT is properly configured - In command prompt, type ant -version
  9. It should give the ant version installed on your machine
Toby answered 15/1, 2013 at 17:1 Comment(3)
If you already have the command prompt open you need to restart it to take effect.Sublimation
@Sublimation you save my day :)Lobule
I was missing the step 6 and your answer is more right when compared to the others.Saintmihiel
Z
23

I expect you to be running on Windows (since you are using %). Simply add a new environment variable (Right-click on My Computer > Properties > Advanced > environment Variable) or using SET ANT_HOME=<path> using command line (in that cas, it will only be active on that command line).

Once set you should be able to verify its value by doing echo %ANT_HOME% in command line

The % sign around the variable indicates it is an environment variable.

For linux use the export ANT_HOME=<path> in command line or in your ~/.profile (persistent, require logout/login). Use echo $ANT_HOME for verification.

Zellazelle answered 15/2, 2012 at 9:2 Comment(2)
Another strong hint toward a Windows installation is the D:\path ^_^'Yunyunfei
Don't put a backslash after path or it won't work. The ant docs warn about this.Vanitavanity
O
4

I had a similar problem of installing JAVA JDK & ANT.

I tried installing JDK this way.

Oracle site --> download JDK setup --> double click on the set up file (on your desktop) --> accept all defaults --> finish.

we need to set environment variable in the deployment system. mycomputer (right click) --> properties --> advanced settings --> Environment variable --> system variable --> add new --> variable name: JAVA_HOME, Variable path: installation path of jdk on you computer --> click ok, ok.

To check the successful installation of Java . windows + R --> cmd --> Java -Version you would see the response as below

C:\Users\PRAX>java -version java version "1.6.0_38" Java(TM) SE Runtime Environment (build 1.6.0_38-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)

This shows that you have successfully installed JDK & set an environment variable too.

ANT installation:

download ant file from http://ant.apache.org/bindownload.cgi choose a mirror & download the zip (zip is the easiest method to set)

unzip the file on your computer --> copy the path (traverse till bin folder).

Now, we need to set an environment variable, Cmd --> set ANT_HOME = installation path --> press Enter if you have correctly entered, it wont throw any error. now execute, echo %ANT_HOME% you would see the result as your installation path.

your work is done.

you can check the environment variable even in computer properties by default after executing the above set up.

Hope, its useful.

Outfoot answered 20/12, 2012 at 6:26 Comment(0)
B
3

ANT_HOME is the path to your ant installation dir, in your case "D:\Installz\apache-ant-1.8.2" and JAVA_HOME is java install dir e.g. "C:\Program Files\Java\jdk1.7.0", that's on my machine

On Windows, %% (percent) symbols are used to signify variables.

so to set both variables you can do either

in command prompt, only valid for the session of the particular command propmt

SET ANT_HOME=D:\Installz\apache-ant-1.8.2
SET JAVA_HOME="C:\Program Files\Java\jdk1.7.0"

or go to System Properties -> Advanced -> Environment Variables and set to new variables

Batista answered 15/2, 2012 at 8:56 Comment(1)
This helped a lot, because 'where ant' was working for me, whilst 'ant -version' wasn't. I had to set the correct JAVA_HOME system variable and then add this to the system variable named path: %JAVA_HOME%\binKinaesthesia
F
1

A more flexible solution is to do all that 'environment stuff' in a batch file that starts your ant script, works also when there are no rights to change the environment variables.
See a similar question that came up recently for details.

Fundamental answered 15/2, 2012 at 20:1 Comment(0)
H
0

I had a similar problem of Configuring ANT.

I tried to configure ANT this way. first add the last version of apache-ant (apache-ant-1.10.14) in the same dir of the JAVA dir. then go to env (Edit the System Environment Variable) > Advanced > Environment Variable and here you need to click on New and Define the name as " ANT_HOME " and put the dir which you left the apache-ant zip folder and save. the last step is double click on path which is in a same column of ANT_HOME, when it is opened then click in one of the free lines and add this direction " %ANT_HOME%\bin " then all done and you can just save the steps. for test: go to Command Line and type "ant", if you get " Buildfile: build.xml does not exist Build failed " then it means all good! if not check the steps again.

Hermie answered 8/9, 2023 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.