Installing Apache Maven on Ubuntu 22.04 - A Step-by-Step Guide

Introduction
What is Apache Maven and Why Should You Install It on Ubuntu 22.04?
Requirements
Below is a list of items that you may need to complete the setup successfully:
1) An on-premise or cloud-hosted VPS running Linux Ubuntu 22.04 LTS
2) An SSH client such as Putty for Windows or Terminal for macOS
3) A fully qualified domain name.
4) A public IP address for the Linux Ubuntu server ( alternatively you can use CloudFlare Zero Trust )
Overview
Below is an overview of the steps covered in this tutorial:
Option 1: Update the system repository and install Apache Maven using APT.
Option 2 (Install from source): Install the Java Development Kit for Ubuntu.
1) Download Apache Maven from the official download page.
2) Extract the downloaded file and export environment variables.
3) Install Apache Maven and verify the software version.
Option 1: Update the system repository and install Apache Maven using APT.
There are two basic ways that you can use to install Apache Maven. You can install it from the official Ubuntu repository using the APT package manager or you can install it from source. To install it from the official Ubuntu repository, open an SSH connection to your Ubuntu 22.04 Server and run the commands below

Option 2 (Install from source): Install the Java Development Kit for Ubuntu.

To save changes made to the maven.sh configuration file. Press CTRL + O, hit the Enter key, then press CTRL + X to exit the file. Activate Apache Maven by running the command: