Cyberithub

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

Advertisements

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.

Advertisements

 

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

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.

Advertisements

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.

Advertisements

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.

Advertisements
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.

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 <package_version> --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.

Leave a Comment