8 C
Texas
angeloma
Senior Writer and partner

How to install Apache Ant on Ubuntu 20.04?

Hello, friends. Apache Ant is a very important tool for the development of applications in Java. So in this post, we will teach you how to install Apache Ant on Ubuntu 20.04.

Apache Ant is an application created in Java sponsored by the Apache foundation that allows automating tasks of compilation and construction of projects. As it is made in Java it is common to use it for Java projects.

Thanks to Apache Ant it is possible to save a lot of time in medium size projects. It is similar to the make tool, the difference is that it uses a file called build.xml where you specify the rules that the application will use.

With this in mind, it is very likely that if you develop applications with Java, you will use Ant.

- Advertisement -

So let’s install it on our Ubuntu 20.04 system.

Install Apache Ant on Ubuntu 20.04

1.- Install Java on Ubuntu 20.04

Apache Ant is a Java technology. It requires Java to run and therefore needs to be installed.

To avoid complications, we can install Java from the official Ubuntu repositories.

So, open a terminal session and execute the following command to update the system:

sudo apt update
sudo apt upgrade

Then, install Java:

sudo apt install openjdk-11-jre
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
at-spi2-core ca-certificates-java fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data
libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1
libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 liblcms2-2 libllvm10 libnspr4 libnss3 libpciaccess0 libpcsclite1 libsensors-config libsensors5
libsm6 libvulkan1 libwayland-client0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
libxcomposite1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1
libxxf86vm1 mesa-vulkan-drivers openjdk-11-jre-headless x11-common x11-utils
Suggested packages:
default-jre cups-common liblcms2-utils pcscd lm-sensors libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
mesa-utils
The following NEW packages will be installed:
at-spi2-core ca-certificates-java fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data
libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1
libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 liblcms2-2 libllvm10 libnspr4 libnss3 libpciaccess0 libpcsclite1 libsensors-config libsensors5
libsm6 libvulkan1 libwayland-client0 libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
libxcomposite1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1
libxxf86vm1 mesa-vulkan-drivers openjdk-11-jre openjdk-11-jre-headless x11-common x11-utils
0 upgraded, 68 newly installed, 0 to remove and 131 not upgraded.
Need to get 71.4 MB of archives.
After this operation, 555 MB of additional disk space will be used.
Do you want to continue? [Y/n]
1.- Install Java on Ubuntu 20.04
1.- Install Java on Ubuntu 20.04

Check that Java is running, showing the installed version:

java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

Now we can continue.

Download and install Apache Ant

With Java installed, we can already start the download of Apache Ant using the wget command.

At the time of writing this post, the last stable version of Apache Ant is 1.10.8 so if you see this post in the future first check the version of Apache Ant and replace the current version by the new one.

So, start the download:

cd /tmp/
wget -c htps://downloads.apache.org/ant/binaries/apache-ant-1.10.8-bin.tar.gz
--2020-09-26 14:52:30-- https://downloads.apache.org/ant/binaries/apache-ant-1.10.8-bin.tar.gz
Resolving downloads.apache.org (downloads.apache.org)… 88.99.95.219, 2a01:4f8:10a:201a::2
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 6884228 (6.6M) [application/x-gzip]
Saving to: ‘apache-ant-1.10.8-bin.tar.gz’
apache-ant-1.10.8-bin.tar.gz 100%[=====================================================================================>] 6.56M 73.5KB/s in 78s
2020-09-26 14:53:50 (86.0 KB/s) - ‘apache-ant-1.10.8-bin.tar.gz’ saved [6884228/6884228]
2.- Download Apache Ant on Ubuntu 20.04
2.- Download Apache Ant on Ubuntu 20.04

Then, decompress it and move the resulting folder to another location like /usr/local/ant so we can use the binary without problems.

tar xvzf apache-ant-1.10.8-bin.tar.gz
sudo mv apache-ant-1.10.8/ /usr/local/ant

To use Apache Ant on Ubuntu 20.04 from any location of the terminal, you have to modify the profile file.

sudo nano /etc/profile

And at the end of the file add the following:

ANT_HOME="/usr/local/ant"
PATH="$PATH:/usr/local/ant/bin"
export ANT_HOME
export PATH

Then save the changes and close the editor.

And to apply the changes in the file you run:

source /etc/profile

Now it’s time to test the installation.

Testing the installation

To verify that the installation has been correct just run the command ant.

ant

And you will have the next output on the screen:

Buildfile: build.xml does not exist!
Build failed

Although the output is an error, the reality is that Apache Ant is well installed because it requires a build.xml file that is not there but the binary is running.

You can also check the installed version of Ant.

ant --version

Output:

Apache Ant(TM) version 1.10.8 compiled on May 10 2020

So, Apache Ant is ready for battle.

Conclusion

Apache Ant is a very important tool for Java application development. With it, you can automate the process of compiling and building packages through predefined rules.

So now that you know how to install your latest version on Ubuntu 20.04, you can take full advantage of it.

Please share this post with your friends and join our Telegram channel. And buy us a coffee.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article