This post shows users and new students that how to Install Apache Ant on Ubuntu 18.04 | 20.04. If your are going to Install Apache Ant on Ubuntu then this post is ideal for you.
Apache Ant (Another Neat Tool) is an open source and Java based build tool that is started by Apache Software Foundation. it is a Java library and build tool or software that is used to automation of software build processes like assemble, compile, test and run Java apps. It is developed and managed by Apache Software Foundation and released on 19 July 2000.
Ubuntu is a Linux Operating System based on Debian and mostly composed of non-profit(free) and open-source software. It is a complete Linux operating system that compatible with desktops, laptops, server and other devices. Ubuntu is Open Source so it is freely available for both community and professional support.
Linux is an operating system, like Windows OS, iOS, and Mac OS. Linux is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system). An operating system is software that manages all hardware resources associated with desktop or laptop. In simple words, the OS(operating system) manages communication between software and hardware.
If you are a learner and looking for a Linux distribution for Learning then Ubuntu Linux Operating System is best for you as a beginning.
Follow below steps to start installing of Apache Ant on Ubuntu:
Step 1: Install OpenJDK 8
Apache Ant is a Java based software or tool so first you will need to installed Java . For do that download the Open JDK . You can also installed Java 8 Development Kit(JDK) or the official Oracle JDK .
For this post, we are going to install OpenJDK.
To install OpenJDK, simply follow below commands:
sudo apt update
sudo apt-get install openjdk-8-jdk openjdk-8-doc openjdk-8-jre-lib
Now run the below command to verify it:
java -version
When you run the command above it will show result similar like below:
Output:
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
Step 2: Install Apache Ant via Apt
To install Apache Ant via apt-get, simply run the below commands:
sudo apt update
sudo apt install ant
To verify if Ant is installed, use the commands below:
Now, Run the below command to verify that Ant is installed :
ant -version
It will show result similar like below :
Output:
Apache Ant(TM) version 1.10.5 compiled on March 28 2019
That’s all!
Above steps shows that how to install Apache Ant using Apt-get
Option 2: Install Ant Manually
If you wish to download and install Apache Ant manually download the simply follow the below steps :
Run the below commands to download and then extract it.
cd /tmp
wget http://mirror.downloadvn.com/apache//ant/binaries/apache-ant-1.10.7-bin.tar.gz
sudo tar -xf apache-ant-1.10.7-bin.tar.gz -C /usr/local
The above command extract the Ant distribution to /usr/local/apache-ant-1.10.7
After that run the below commands to create a symbolic link for the Ant distribution.
sudo ln -s /usr/local/apache-ant-1.10.7/ /usr/local/ant
Next, create a ant.sh file in /etc/profile.d folder.
sudo nano /etc/profile.d/ant.sh
Now, Copy and paste these below lines into the newly created file and save it.
export ANT_HOME=/usr/local/ant
export PATH=${ANT_HOME}/bin:${PATH}
Save the file and exit.
Next, Run the below command to activate the above environment variables.
source /etc/profile
If want to verify Ant version then simply run the below commands :
ant -version
It will show the result similar like below:
Output:
Apache Ant(TM) version 1.10.7 compiled on September 1 2019
That’s all
If you find any error and issue in above steps , please use comment box below to report