Apache Ant™ is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing them to compile, assemble, test, and run Java applications. Ant can also be used effectively to build non-Java applications, for instance, C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Apache Ant queries.
In this context, we shall look into how to install Apache Ant on Ubuntu 20.04 LTS.
1. Perform System Update
First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal:
$ sudo apt update
$ sudo apt upgrade
2. Install Java
Run the commands below to install Java:
$ sudo apt install openjdk-11-jre
Check that Java is running, showing the installed version:
$ java --version
3. Install Apache Ant on the system
Here, you will learn 3 different ways on installing Ant.
i. Install Apache Ant using Snaps
To do this, run the below commands:
$ sudo apt install snapd
$ sudo snap install ant --classic
ii. Install Apache Ant using Apt
Execute the below commands:
$ sudo apt update
$ sudo apt install ant
iii. Install Apache Ant from Source
Now we download the lasted version of Apache Ant from the official page:
$ wget https://mirror-hk.koddos.net/apache//ant/binaries/apache-ant-1.10.9-bin.tar.gz
$ sudo tar -xf apache-ant-1.10.9-bin.tar.gz -C /usr/local
Next, create a symbolic link to the Ant distribution by running the commands below:
$ sudo ln -s /usr/local/apache-ant-1.10.9/ /usr/local/ant
After that, create a ant.sh file at /etc/profile.d folder:
$ sudo nano /etc/profile.d/ant.sh
export ANT_HOME=/usr/local/ant
export PATH=${ANT_HOME}/bin:${PATH}
Save and exit also activates the above environment variables:
source /etc/profile
You can verify the Ant version by running the commands:
$ ant -version
This article covers the process of installing Apache Ant on your Ubuntu 20.04 LTS Focal Fossa system. In fact, Apache Ant is a software tool for automating software build processes especially on Java environments. It is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications.