How to install ANT on LINUX

Apache Ant is a Java library and command-line tool that help building software.
How to install:

  • Create downloads directory if you dont have one
  • Download tar version from http://ant.apache.org/bindownload.cgi
  • Extract
  • Rename the new directory as ant
  • Insert the path into ANT_HOME
  • Update the global PATH variable to include ANT_HOME
  • Run the Ant script fetch.xml to install almost all the dependencies the optional Ant tasks need.

See actual commands:

[bash ~]$ mkdir downloads
[bash ~]$ cd downloads/
[bash downloads]$
[bash downloads]$
[bash downloads]$ wget http://mirror.candidhosting.com/pub/apache//ant/binaries/apache-ant-1.8.2-bin.tar.gz
[bash downloads]$ tar -zxvf apache-ant-1.8.2-bin.tar.gz
[bash downloads]$ mv apache-ant-1.8.2 ant
[bash downloads]$ ANT_HOME=/home/ATOMANT/ilanh/downloads/ant
[bash downloads]$ PATH=$PATH:${ANT_HOME}/bin
[bash downloads]$ ant -f fetch.xml -Ddest=system

Note: see http://ant.apache.org/manual/install.html#setup

5 Comments
  1. Ray says:

    Hi,

    This was really helpful.

    Thanks!

  2. David says:

    Thanks for sharing.
    Should I go to ant directory to run the following command? Otherwise fetch.xml is not found.
    [bash ant]$ ant -f fetch.xml -Ddest=system

  3. Ankit says:

    Very helpful
    Thanks dude!!!!

  4. Harold says:

    Awesome post! Very clear, concise and it works!
    Thank you very much!

  5. Fabio says:

    Hi, I am trying to install ant on linux , did the installation and added his way to the $ PATH however am having the following error:

    echo $JAVA_HOME
    /usr/local/java/jre1.7.0_45

    echo $ANT_HOME
    /usr/local/java/apache-ant-1.9.4

    ant -version
    Error: JAVA_HOME is not defined correctly.
    We cannot execute /usr/local/java/jre1.7.0_45/bin/java

    How to troubleshoot this?

Leave a Reply

*