Categories: Ubuntu

How to Install Apache Ant on Ubuntu 20.04 LTS (Focal Fossa)

In this article, we will see how to install apache ant on Ubuntu 20.04 LTS (Focal Fossa). Apache Ant is a Java library and command line tool used for building Java and Non-Java applications. It is responsible for compiling, assemble, test and run Java applications. It is very similar to make tool but is extremely flexible  and does not impose coding conventions or directory layouts to the Java projects which adopt it as a build tool. Apache Ant is written in Java and has rich set of libraries.

It also provides the capability to users to develop their own libraries contains ant tasks and types. It is extremely simple to install and use on almost all the famous platforms such as Windows, Linux and Mac. Here we will see the steps to install Apache Ant on Ubuntu 20.04 LTS based systems.

 

Sponsored

How to Install Apache Ant on Ubuntu 20.04 LTS (Focal Fossa)

Also Read: How to Install Blender on Linux Using 5 Easy Steps

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get and sdkman utility available in your Server.

d) You should have OpenJDK 17 installed in your Server.

 

Step 2: Update Your Server

It is best to download and install all the latest available updates from default Ubuntu repo by using sudo apt update && sudo apt upgrade before installing any new packages in your system.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Hit:4 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:5 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:6 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:7 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease
Hit:8 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:9 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:10 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Hit:11 https://download.sublimetext.com apt/stable/ InRelease
Hit:12 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:13 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Hit:14 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
.................................................

 

Step 3: Verify Java Installation

Since Apache Ant has dependency on Java installation, so before proceeding to install Ant on your system, it is imperative to make sure latest Java version is already available in your system. You can check the current installed version by using java --version command as shown below.

cyberithub@ubuntu:~$ java --version
openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Ubuntu-120.04.2)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Ubuntu-120.04.2, mixed mode, sharing)

 

Step 4: Install Apache Ant

In the next step, you can install Apache Ant by using any of the below methods.

Sponsored

a) Using APT

If you are looking to install apache ant from default Ubuntu repo then you need to use sudo apt install ant command as shown below. This will download and install the ant package along with all its dependencies.

cyberithub@ubuntu:~$ sudo apt install ant
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ant-optional
Suggested packages:
ant-doc antlr javacc junit junit4 jython libactivation-java libbcel-java libbsf-java libcommons-logging-java libcommons-net-java libmail-java
libjaxp1.3-java libjdepend-java libjsch-java liblog4j1.2-java liboro-java libregexp-java libxalan2-java libxml-commons-resolver1.1-java libxz-java
The following NEW packages will be installed:
ant ant-optional
0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
Need to get 2,468 kB of archives.
After this operation, 3,415 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
..............................................................

b) Using SDKMAN

Second method you can use to install apache ant is through sdkman. If you have this tool installed in your system then you can simply use sdk install ant command to install apache ant in your System as you can see below. Check How to Install SDKMAN on Linux Using 7 Easy Steps article to know more about the SDKMAN installation on Linux.

cyberithub@ubuntu:~$ sdk install ant

Downloading: ant 1.10.13

In progress...

###################################################################################################################################################### 100.0%

Installing: ant 1.10.13
Done installing!


Setting ant 1.10.13 as default.

 

Step 5: Check Version

After successful installation, you can check the current installation version of ant using ant -version command as shown below.

cyberithub@ubuntu:~$ ant -version
Apache Ant(TM) version 1.10.7 compiled on October 24 2019

 

Step 6: Uninstall Apache Ant

Once you are done using Apache Ant, you can also choose to uninstall it from your system by using any of the below methods depending on how you have installed it.

a) Using APT

If you installed apache ant using apt package manager then to uninstall, you just need to use sudo apt remove ant command as shown below. Please note that this will also uninstall another package called ant-optional along with the ant package. So be careful and check all the package dependencies on ant before removing this package.

cyberithub@ubuntu:~$ sudo apt remove ant
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
ant ant-optional
0 upgraded, 0 newly installed, 2 to remove and 2 not upgraded.
After this operation, 3,415 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 254235 files and directories currently installed.)
Removing ant-optional (1.10.7-1) ...
Removing ant (1.10.7-1) ...
Processing triggers for man-db (2.9.1-1) ...

b) Using SDKMAN

If you installed apache ant using sdkman then to uninstall you need to use sdk uninstall ant --force command. Since our current installed version is 1.10.13 so here to uninstall we are using sdk uninstall ant 1.10.13 --force command as shown below.

cyberithub@ubuntu:~$ sdk uninstall ant 1.10.13 --force
removed ant 1.10.13.
Ubuntu Server Admin

Recent Posts

Building RAG with enterprise open source AI infrastructure

One of the most critical gaps in traditional Large Language Models (LLMs) is that they…

1 hour ago

Life at Canonical: Victoria Antipova’s perspective as a new joiner in Product Marketing

Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…

1 day ago

What is patching automation?

What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…

2 days ago

A beginner’s tutorial for your first Machine Learning project using Charmed Kubeflow

Wouldn’t it be wonderful to wake up one day with a desire to explore AI…

3 days ago

Ubuntu brings comprehensive support to Azure Cobalt 100 VMs

Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…

3 days ago

Ubuntu Weekly Newsletter Issue 870

Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…

4 days ago