19.6 C
Texas
angeloma
Senior Writer and partner

How to install Apache Ant on Debian 10?

The development of applications is full of tools aimed at improving the time of construction of the applications. Especially when it comes to repetitive tasks that can be automated. In the case of Java, there is Apache Ant that helps to manage projects. So in this post, we will teach you how to install Apache Ant on Debian 10.

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 Debian 10 system.

Install Apache Ant on Debian 10

1.- Install Java on Debian 10

Apache Ant is created with Java technology. So it requires that the system on which it runs has Java installed correctly.

So, installing Java on Debian 10 is the first step in this tutorial.

To do this, open a terminal and run the following command:

:~$ sudo apt install openjdk-11-jre
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
adwaita-icon-theme at-spi2-core ca-certificates-java fontconfig fonts-dejavu-extra glib-networking glib-networking-common glib-networking-services
gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0
libatk1.0-data libatspi2.0-0 libcairo-gobject2 libcroco3 libdatrie1 libepoxy0 libfribidi0 libgail-common libgail18 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-bin
libgdk-pixbuf2.0-common libgif7 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libharfbuzz0b libjson-glib-1.0-0
libjson-glib-1.0-common libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libproxy1v5 librest-0.7-0 librsvg2-2 librsvg2-common libsoup-gnome2.4-1 libsoup2.4-1
libthai-data libthai0 libwayland-client0 libwayland-cursor0 libwayland-egl1 libxcursor1 libxkbcommon0 openjdk-11-jre-headless
Suggested packages:
default-jre gvfs librsvg2-bin fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
adwaita-icon-theme at-spi2-core ca-certificates-java fontconfig fonts-dejavu-extra glib-networking glib-networking-common glib-networking-services
gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0
libatk1.0-data libatspi2.0-0 libcairo-gobject2 libcroco3 libdatrie1 libepoxy0 libfribidi0 libgail-common libgail18 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-bin
libgdk-pixbuf2.0-common libgif7 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libharfbuzz0b libjson-glib-1.0-0
libjson-glib-1.0-common libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libproxy1v5 librest-0.7-0 librsvg2-2 librsvg2-common libsoup-gnome2.4-1 libsoup2.4-1
libthai-data libthai0 libwayland-client0 libwayland-cursor0 libwayland-egl1 libxcursor1 libxkbcommon0 openjdk-11-jre openjdk-11-jre-headless
0 upgraded, 57 newly installed, 0 to remove and 53 not upgraded.
Need to get 68.8 MB of archives.
After this operation, 293 MB of additional disk space will be used.
Do you want to continue? [Y/n]
1.- Install Java on Debian 10
1.- Install Java on Debian 10

Once the installation is complete, you will be able to verify the installed version of Java.

:~$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1deb10u1, mixed mode, sharing)

2.- Java on Debian 10
2.- Java on Debian 10

This indicates that Java is correctly installed and ready for action.

2.- Download and install Apache Ant on Debian 10

Apache ant is available from the official Debian repositories. So installing it is quite simple. The problem is that we won’t have the latest stable version and this makes us miss out on the news.

To avoid this, it is best to download and install Apache Ant ourselves and then even choose which version we want to install. Of course, we will choose the latest one.

To do this, use the wget command to download the Ant file.

:~$ cd /tmp/
:~$ wget -c https://downloads.apache.org/ant/binaries/apache-ant-1.10.7-bin.zip
3.- Download Apache Ant on Debian 10
3.- Download Apache Ant on Debian 10

In my case I used another mirror that was more suited to my internet connection.

Then, unzip it because it is a zip file. In case the unzip command is not available, install it.

:~$ sudo apt install unzip
:~$ unzip apache-ant-1.10.7-bin.zip

Now move the generated folder to /usr/local

:~$ sudo mv apache-ant-1.10.7/ /usr/local/ant

Now, a bash configuration file must be edited so that Ant can be run from any document.

:~$ 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
4.- Editing the profile configuration file
4.- Editing the profile configuration file

Save the changes CTRL + O and then exit the file CTRL + X

Then, apply the changes with the following command:

:~$ source /etc/profile

And finally, try the execution of Ant. To do this, choose a random folder and within it execute:

:~$ ant

And you’ll have to get this output on screen:

Buildfile: build.xml does not exist!
Build failed

Do not panic. This indicates that ant is functioning properly. What happens is that ant requires a file called build.xml where the rules are specified. The error is that the file does not exist, but ant is working.

Finally, check the installed version.

:~$ ant -version
Apache Ant(TM) version 1.10.7 compiled on September 1 2019

So, Apache Ant is ready for the job. Enjoy it.

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 Debian 10, you can take full advantage of it.

Please share this post with your friends and join our Telegram channel.

- 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