Apache Ant is an open-source tool for automating Java program build process. Similar to how the make utility builds an executable from source code and libraries using a Makefile, Apache Ant builds a Java project from its source code and libraries by using a similar XML file.
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 CentOS 8.
Steps to Install Apache Ant on CentOS 8
1. Perform System Update
First, let's start by ensuring your system is up-to-date:
$ sudo dnf install epel-release
$ sudo dnf update
2. Install Java on the system
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.
To Install OpenJDK 11, run the below command:
$ sudo dnf install java-11-openjdk-devel
To Install OpenJDK 8, execute the below command:
$ sudo dnf install java-1.8.0-openjdk-devel
To Verify Java version installed, run the below command:
$ java -version
3. Install Apache Ant on the system
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:
Make the script executable by using the chmod command:
$ sudo chmod +x /etc/profile
Save and exit also activates the above environment variables. Load the environment variables for the current session by using the following command:
$ source /etc/profile
How to verify Apache Ant installation ?
To verify if Apache Ant is installed properly use the ant -v command which will display the Apache Ant version:
$ ant -version
[Need assistance in installing Software on Linux system ? We can help you. ]