Welcome, my friend. Today, you will learn how to install Ant on CentOS 9 Stream. Thanks to this tool, we will be able to automate the process of compiling and creating Java packages. Let’s take a look at it.
Introduction—What is Ant?
According to the official Ant documentation:
Apache Ant is a Java library and command line tool whose mission is to drive the processes described in the build files as mutually dependent targets and extension points.
As the developers themselves say, Ant’s main mission is to create Java packages quickly and easily with established rules. These tasks or rules are usually set in a
build.xml file that we can then run with some commands in the terminal.
Ant is extremely flexible and does not impose coding conventions or directory layouts on Java projects that adopt it as a build tool.
As we can notice, it is an important tool in Java development. Let’s go for it.
Install Java on CentOS 9 Stream
Ant is built with Java, so we have to install this language to be able to install and use it. For this, we leave you our post.
Once Java is installed without problems, you can continue.
Install Ant on CentOS 9 Stream
Now we can install Ant. The best way to do it is to get the latest stable version of it.
First, open a terminal and install some necessary packages
sudo dnf install wget tar nano
And then thanks to
wget you can start the download:
wget -c http://mirrors.advancedhosters.com/apache/ant/binaries/apache-ant-1.10.12-bin.tar.gz
Then unzip it
tar vxfz apache-ant-1.10.12-bin.tar.gz
Now move it to a system directory such as
sudo mv apache-ant-*/ /usr/local/ant
The next step is to set the environment variables correctly so that Ant can work in the best possible way.
Create a file for this purpose:
sudo nano /etc/profile.d/ant.sh
And add the following content:
ANT_HOME="/usr/local/ant" PATH="$PATH:/usr/local/ant/bin" export ANT_HOME export PATH
Save the changes and close the editor. To apply the changes, give the file execute permissions:
sudo chmod +x /etc/profile.d/ant.sh
And apply it:
Finally, you can verify the installation of Ant with the command line:
You will get an output screen like this:
In this post, you learned how to install Ant on CentOS 9 Stream. This way, you will be able to take advantage of it in your Java projects. I hope this post is useful for you.