How to install Apache Ant on CentOS

Apache Ant is an open-source tool for automating Java program build process. Similar to how the make utility builds an executable from source code and libraries using a Makefile, Apache Ant builds a Java project from its source code and libraries by using a similar XML file.

If you would like to install Apache Ant on CentOS, follow this guideline.

First of all, you need to install Java Development Kit, since Apache Ant will use JDK during its build process.

Then go ahead and install Apache Ant, using its binary distribution from the official Apache web site.

$ wget http://www.us.apache.org/dist/ant/binaries/apache-ant-1.9.2-bin.tar.gz
$ sudo tar xvfvz apache-ant-1.9.2-bin.tar.gz -C /opt
$ sudo ln -s /opt/apache-ant-1.9.2 /opt/ant

You then have to set up ANT_HOME environment variable, and include Ant binary in your path, as follows.

$ sudo sh -c 'echo ANT_HOME=/opt/ant >> /etc/environment'
$ sudo ln -s /opt/ant/bin/ant /usr/bin/ant

Log out and log back in, to reload the environment variables defined in /etc/environment.

Finally, verify that Apache Ant is successfully installed.

$ ant -version
Apache Ant(TM) version 1.9.2 compiled on July 22 2013

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

One thought on “How to install Apache Ant on CentOS

Leave a comment

Your email address will not be published. Required fields are marked *

Current day month ye@r *