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.
1. Perform System Update
First, let's start by ensuring your system is up-to-date:
$ sudo dnf install epel-release
$ sudo dnf update2. 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-develTo Install OpenJDK 8, execute the below command:
$ sudo dnf install java-1.8.0-openjdk-develTo Verify Java version installed, run the below command:
$ java -version3. 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/antThen, 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/profileAnd add the following lines:
ANT_HOME="/usr/local/ant"
PATH="$PATH:/usr/local/ant/bin"
export ANT_HOME
export PATHMake the script executable by using the chmod command:
$ sudo chmod +x /etc/profileSave and exit also activates the above environment variables. Load the environment variables for the current session by using the following command:
$ source /etc/profileTo verify if Apache Ant is installed properly use the ant -v command which will display the Apache Ant version:
$ ant -versionThis article covers the process of installing Apache Ant on your CentOS 8 system. In fact, Apache Ant is a Java library and command-line tool that help building software. Ant supplies a number of built-in tasks that allows to compile, assemble, and run Java applications. Its build files are written in XML so it is open standard, portable and easy to understand.