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 the step-by-step installation of Apache Ant on CentOS 8.
Prerequisites
- A server running one of the following operating systems: CentOS 8.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
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 both Java versions on any system and use them 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 check the official Apache Ant website.