How To Install Apache Ant on CentOS 8

Install Apache Ant on CentOS 8

In this tutorial, we will show you how to install Apache Ant on CentOS 8. For those of you who didn’t know, 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.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step by step installation of Apache Ant on CentOS 8.

Install Apache Ant on CentOS 8

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo dnf install epel-release
sudo dnf update

Step 2. Installing Java.

Currently, there are two LTS versions of OpenJDK – OpenJDK 8 and OpenJDK 11. You can also install the both Java version on any system and use as per your requirements.

  • Installing OpenJDK 11.
sudo dnf install java-11-openjdk-devel
  • Installing OpenJDK 8.
sudo dnf install java-1.8.0-openjdk-devel

Verify Java version:

java -version

Step 3. Installing Apache Ant on CentOS 8.

Now we download the lasted version of Apache Ant from the official page:

wget https://mirrors.gigenet.com/apache//ant/binaries/apache-ant-1.10.9-bin.zip
sudo unzip apache-ant-1.10.9-bin.zip
sudo mv apache-ant-1.10.7/ /usr/local/ant

Then, make Ant available as a command to all users of the system. This will make it easy to use and run from any folder:

sudo nano /etc/profile

And add the following lines:

ANT_HOME="/usr/local/ant"
PATH="$PATH:/usr/local/ant/bin"
export ANT_HOME
export 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
Apache Ant(TM) version 1.10.9 compiled on November 06 2020

Congratulations! You have successfully installed Apache Ant. Thanks for using this tutorial for installing Apache Ant on your CentOS 8 system. For additional help or useful information, we recommend you to check the official Apache Ant website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!