Installing Ant on Linux from command line
Prerequisites
Ant requires Java runtime to work. See Installing Open JDK on Linux for instructions on how to do that. This document explains how to install Ant build tool on Debian Linux from binary distribution.
Download Ant binary distribution
You can download Ant from this location: Apache Ant download. Scroll down to where it says Mirror and choose the mirror server closest to you. Or just scroll down lower and click on the download link. Save that file to a directory on your computer. I'm going to use Downloads as a download directory name from now on.
Unpack and install Ant
I prefer to install additional software in /opt directory. You can choose any other directory. You need to login as root to make changes to /opt directory. If you're using Gnome desktop you can open Root Terminal window. Check main menu under Applications / Accessories / Root Terminal. If you want to you can log in as root from a regular terminal window using su command. Open a terminal and press ENTER after each command:
cd /opt
mkdir ant
cd ant
mv /home/<user>/Downloads/apache-ant-VERSION.zip .
unzip apache-ant-VERSION.zip
rm apache-ant-VERSION.zip
That should create a directory called apache-ant-VERSION. I like to provide a symlink (a.k.a. symbolic or soft link) called default pointing to the current software version:
cd /opt/ant
ln -s apache-ant-VERSION default
This makes things easier when upgrading to a newer version of Ant. All you need to do is remove the default symlink, then create it again but point it to another Ant version. For example:
cd /opt/ant
rm default
unzip apache-ant-NEW-VERSION.zip
ln -s apache-ant-NEW-VERSION default
If directory structure is the same everything should work out of the box after Ant version upgrade.
Expose Ant executable to all users
On Debian Linux systems directory /etc/alternatives contains links to all exposed binaries. You need to have root access to make changes there.
cd /etc/alternatives
ln -s /opt/ant/default/bin/ant
Then link all exposed binary files located in /etc/alternatives directory to /usr/local/bin:
cd /usr/local/bin
ln -s /etc/alternatives/ant
Export ANT_HOME property
If you want to set ANT_HOME system property do this (as root):
cd /etc
vi profile
Add this line at the end:
export ANT_HOME=/opt/ant/default
Save and close. Changes will not be visible until you logout and login again. Note that when using Gnome terminal window closing it and opening it again does not really log you out. So check for ANT_HOME enrionment property after you reboot Linux. Run this command:
export
That should print all system properties. Look for ANT_HOME at the top.