Tutorial: How to Install Apache Ant on Ubuntu Linux
Sorry if there are any spelling or grammatical errors, I’m learning English… :)
On my last article I’ve show you how to install Java Development Kit(JDK) on Ubuntu Linux. In this tutorial we will try to install Apache Ant or Ant in short. Before going more deeper, some of you may ask, What is ant?
Apache Ant is a software tool for automating software build processes. It is similar to make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects.
If you ever try building some application from source in Linux, I bet you have used build tool called make. Ant is very similar to it but Ant use XML based configuration for it’s build process. Ant is also used internally by NetBeans IDE to compile project. OK, enough talk let’s install Ant.
My Environment
- My $HOME is located in /home/astadev
- I put Ant package in $HOME/archive/a
- I extract the package to $HOME/programs
- My Ant version is 1.7.1
Pre-Installation
You must have Java installed first, go to my Java installation tutorial if you have not install Java yet.
Installation
Download the latest version of Ant from http://ant.apache.org. Saved to some location e.g: I save to $HOME/archive. First we need to extract the package.
$ tar -jxvf ~/archive/a/apache-ant-1.7.1-bin.tar.bz2 -C ~/programs $ cd programs $ ln -s apache-ant-1.7.1 ant
Note: if your ant package in .gz format use -zxvf instead.
The next step is to add Apache Ant directory to shell environment variables. So we need to edit .bashrc file located in our home directory.
$ gedit ~/.bashrc
Put this at the end of .bashrc file, after editing your file look something like this:
JAVA_HOME=/usr/local/java JAVA_BIN=$JAVA_HOME/bin ANT_HOME=/home/astadev/programs/ant PATH=$PATH:$JAVA_HOME:$JAVA_BIN:$ANT_HOME/bin export PATH
Save the file, and then open new bash session by pressing CTRL-Shift-T. Try to execute ant.
$ ant Buildfile: build.xml does not exist! Build failed
Error? No. Error above indicate that ant command is recognized by shell but it did not find build.xml file that needed to compile ant projects. So, it’s absolutely normal and the installation was successful.
Comment and feedback are welcome :).
References:
http://ant.apache.org/
http://en.wikipedia.org/wiki/Apache_Ant







