Hamsa K
Editor
5 min read | 3 years ago

How to Install Apache Ant on Centos 8

Install Apache Ant on Centos 8

Apache Ant is a Java library and command-line tool and it supplies a number of built-in tasks allowing 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.Ant is extremely flexible and does not impose coding conventions or directory layouts to the Java projects which adopt it as a build tool.

Step 1: Install Java

First we need to install Java 8 or higher version.

[root@localhost ~]# dnf install java-11-openjdk

check java version with following command.

java --version

output:

[root@localhost ~]# java --version
openjdk 11.0.9 2020-10-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)


Also Read -> How to Install JAVA 13 on Centos 8

Step 2: Install Apache Ant

you can download the latest version of Apache ant from Apache Ant release download page.

After download you can extract it using unzip command and rename as ant.

Also Read -> How to Install PHP 7.4 on Centos 8

[root@localhost ~]# cd /opt
[root@localhost opt]# wget https://mirror-hk.koddos.net/apache/ant/binaries/apache-ant-1.10.9-bin.zip
[root@localhost opt]# unzip apache-ant-1.10.9-bin.zip
[root@localhost opt]# mv apache-ant-1.10.9 ant

Next, create a symbolic link to the Ant distribution by running below command.

ln -s /opt/ant/bin/ant /usr/bin/ant


Also Read -> How to Install Mariadb on Centos 8

Step 3: Setup Environment Variables

Create one new file named as ant.sh in /etc/profile.d directory.

vi /etc/profile.d/ant.sh

Add following content to above file.

#!/bin/bash
ANT_HOME=/opt/ant
PATH="$PATH:/opt/ant/bin"
export ANT_HOME
export PATH

save the file and exit. and make it executable with below command.

chmod +x /etc/profile.d/ant.sh

Then load the the environment variables permanently.

source /etc/profile.d/ant.sh

verify ant version as shown below.

[root@localhost ~]# ant -version
Apache Ant(TM) version 1.10.9 compiled on September 27 2020

Also you can check Ant home path and ant help.

[root@localhost ~]# echo $ANT_HOME
/opt/ant
[root@localhost ~]# ant --help

That's it. you have successfully installed Apache Ant on centos 8 server.

Also Read -> How to Install DNS Server in Centos 8



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy