How to install Apache Maven on Ubuntu 20.04?

Windows Articles

How to enable and disable SMB1/SMB2 in Windows 10

Hello! Windows 10 is an operating system that integrates various protocols to ensure its use with internal and external processes. Indeed, one...

Install Wine 5 on Debian 10

Hi, folks. In this post, I will help you install Wine 5 on Debian 10. Wine is one of...

Is ReactOS a real alternative to Windows?

Oh! The eternal struggle of computer operating systems. Windows vs. GNU/Linux and Mac as a distant spectator However, there are also interesting...

How to install Firebird on Ubuntu 20.04/ 18.04?

Database management systems are sufficient for many kinds of projects. Of course, they abound with MySQL / MariaDB or PostgreSQL popular but...

How to disable Firewall in Windows Server 2019/2016

Hello! The Firewall performs an essential security task on any version of Windows Server. In fact, it has the mission of preventing...
angeloma
angeloma
Senior Writer and partner

Java is still one of the most practical languages used by many developers. This is thanks to the fact that it continues to accomplish everything it is asked to do. Despite this, other tools are also required to help speed up the process of development and compilation of the project. Today I’ll show you how to install a tool that will help you a lot. Today I will teach you how to install Apache Maven on Ubuntu 20.04

To manage projects done in Java, there is no better tool than Apache Maven. This fantastic tool, belonging to the Apache foundation, comes with predefined objectives to perform certain clearly defined tasks, such as code compilation and packaging.

Many features make Maven a great tool. However, the key is that Maven is ready for network use. Also, its functions are made extensible by the ability to install plugins. Finally, Maven relies on the Project Object Model (POM) to describe the project, as well as its dependencies for later deployment.

Installing Apache Maven on Ubuntu 20.04

Before starting the installation of Apache Maven, it is advisable to perform a complete update to the operating system.

So, open a terminal or connect via SSH to your server:

:~$ sudo apt update
:~$ sudo apt upgrade

Once all the packages have been installed without problems, we can start.

1.- Install Java on Ubuntu 20.04

Apache Maven is created in Java, so the operating system where it is going to be installed has to have Java. This, in Ubuntu 20.04 is not a problem.

To install Java you can execute the following command:

:~$ sudo apt install openjdk-11-jre openjdk-11-jdk
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 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0
libice-dev libice6 libllvm9 libnspr4 libnss3 libpciaccess0 libpcsclite1 libpthread-stubs0-dev libsensors-config libsensors5 libsm-dev libsm6 libvulkan1
libwayland-client0 libx11-dev libx11-xcb1 libxau-dev libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
libxcb1-dev libxcomposite1 libxdamage1 libxdmcp-dev libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt-dev libxt6
libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers openjdk-11-jdk-headless openjdk-11-jre-headless x11-common x11-utils x11proto-core-dev x11proto-dev
xorg-sgml-doctools xtrans-dev
Suggested packages:
default-jre libice-doc pcscd lm-sensors libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-11-demo openjdk-11-source visualvm 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 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0
libice-dev libice6 libllvm9 libnspr4 libnss3 libpciaccess0 libpcsclite1 libpthread-stubs0-dev libsensors-config libsensors5 libsm-dev libsm6 libvulkan1
libwayland-client0 libx11-dev libx11-xcb1 libxau-dev libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
libxcb1-dev libxcomposite1 libxdamage1 libxdmcp-dev libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt-dev libxt6
libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless x11-common x11-utils
x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev
0 upgraded, 77 newly installed, 0 to remove and 0 not upgraded.
Need to get 294 MB of archives.
After this operation, 789 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

This will install Java version 11, which is LTS, and already comes in the official repositories of the distribution.

If you want to install Java version 14, you can do it through this tutorial.

Now, verify that Java has been installed correctly, executing the Java command, for example, to know the version installed:

:~$ java --version
openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
2.- Java installed
2.- Java installed

This indicates that Java has been installed and is working properly.

2.- Download, install and test Apache Maven on Ubuntu 20.04

Now we can download Apache Maven from one of the Apache mirrors. We do this intending to get the latest stable version and thus take better advantage of the features offered.

So, go to the /tmp directory from there with the help of the wget command and download.

:~$ cd /tmp/
:~$ wget -c http://mirrors.advancedhosters.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
--2020-05-14 05:15:57-- http://mirrors.advancedhosters.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
Resolving mirrors.advancedhosters.com (mirrors.advancedhosters.com)… 213.174.147.249, 2a02:b48:6:1::2
Connecting to mirrors.advancedhosters.com (mirrors.advancedhosters.com)|213.174.147.249|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 9506321 (9.1M) [application/octet-stream]
Saving to: ‘apache-maven-3.6.3-bin.tar.gz’
apache-maven-3.6.3-bin.tar.gz 100%[=====================================================================================>] 9.07M 1.03MB/s in 9.3s
2020-05-14 05:16:07 (1001 KB/s) - ‘apache-maven-3.6.3-bin.tar.gz’ saved [9506321/9506321]
3.- Downloading Apache Maven on Ubuntu 20.04
3.- Downloading Apache Maven on Ubuntu 20.04

At the moment, the last stable version of Apache Maven is 3.6.3

Then, decompress the file and move it to /opt/

:~$ tar -zxvf apache-maven-3.6.3-bin.tar.gz
:~$ sudo mv apache-maven-3.6.3 /opt/maven

And to make Apache Maven available from anywhere on the prompt, a new file has to be created within the bash profile.

:~$ sudo nano /etc/profile.d/maven.sh

And add the following:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
4.- Making Apache Maven available from the terminal
4.- Making Apache Maven available from the terminal

Save the changes and close the file.

Apply the changes by running this command:

:~$ source /etc/profile.d/maven.sh

Finally, to test Apache Maven, just show the installed version.

:~$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-26-generic", arch: "amd64", family: "unix"
5.- Testing Apache Maven on Ubuntu 20.04
5.- Testing Apache Maven on Ubuntu 20.04

So, enjoy it because it is properly installed.

Conclusion

Apache Maven is a very important tool in the development of projects, especially if they are Java. Its installation is not difficult but its benefits are many.

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

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to enable and disable SMB1/SMB2 in Windows 10

Hello! Windows 10 is an operating system that integrates various protocols to ensure its use with internal and external processes. Indeed, one...

Install Wine 5 on Debian 10

Hi, folks. In this post, I will help you install Wine 5 on Debian 10. Wine is one of...

Is ReactOS a real alternative to Windows?

Oh! The eternal struggle of computer operating systems. Windows vs. GNU/Linux and Mac as a distant spectator However, there are also interesting...

How to install Firebird on Ubuntu 20.04/ 18.04?

Database management systems are sufficient for many kinds of projects. Of course, they abound with MySQL / MariaDB or PostgreSQL popular but...

How to disable Firewall in Windows Server 2019/2016

Hello! The Firewall performs an essential security task on any version of Windows Server. In fact, it has the mission of preventing...