How to Install Apache Maven on Ubuntu 22.04 – Linux Hint

Apache Maven is an open source utility that allows you to automate the Java project development procedure. It can also be used for Ruby, C# and other programming languages. On Linux-based systems such as Ubuntu 22.04, Apache Maven is a well-known tool for developing Java-related projects. It is hosted by the maven project, which was once part of the Jakarta Project until it broke up.

This article will demonstrate the method of installing Apache Maven on Ubuntu 22.04 using two different methods. So, let’s get started!

Method 1: Installing Apache Maven on Ubuntu 22.04 Using apt You need to follow the step-by-step instructions given below to install Apache Maven on Ubuntu 22.04 using the official APT repository. Step 1: Update the system repositories First of all, open the terminal by pressing “CTRL+ALT+T”

in Ubuntu 22.04

and type the commands

given below to

update the system repositories:

install apache maven ubuntu 01

Also update the system packages

:

<img src

=”https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-02.png”

alt=”” />

Step 2: Install Apache Maven on Ubuntu

22.04In the next step, run the following command for Apache Maven installation on Ubuntu 22.04 system

: install apache maven ubuntu 03 Wait a

few minutes as Apache Maven will take a while to install

:

<img src

=”https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-04.png”

alt=”” />

Step 3: Checkthe version of Apache Maven Finally, check the version of Apache Maven that you have installed on your

Ubuntu 22.04:

install apache maven ubuntu 05

Now, let’s take a look at the

manual Apache Maven installation procedure.

Method 2: Installing Apache Maven on Ubuntu 22.04 Using

Manual

Method For experienced Linux users, the manual method to install Apache Maven is more suitable as it allows you to download and install the latest version. Do you want to manually install Apache Maven

? Follow the procedure below.

Step

1: InstallJava First of all, make sure Java is installed on your Ubuntu 22.04; if you don’t have it, use the given command for your installation

:

install apache maven ubuntu 06

Step 2: Download Apache Mavenlatest version Then type the following “wget” to download the latest version

of Apache Maven from the official website: install apache maven ubuntu 07

Step 3: Extract the downloaded Apache Maven packageNow, go to the “/tmp” directory with the help of “cd” command:

<img

src=”https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-08.png”

alt=””

/>

then run the following command to extract the downloaded Apache Maven archive file

: install apache maven ubuntu 09

Wait a few minutes

:

<img src

=”https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-10.png” alt=”” />

After extracting the required package, copy it to the “/opt/” directory

:

<img src="https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-11.png" alt=

“” />

Step 4: Configureenvironment variables In the next step, we will configure the environment variables by creating a maven script file “maven.sh” inside the “/etc.profile.d” directory:

install apache maven ubuntu 12

In the open “maven.sh” file, paste the following code and press “CTRL+O” to save it:

<img src="https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-13.png" alt=

” />

then type the following command to enable the executable permission of the created Apache Maven script

: install apache maven ubuntu 14

After doing so, load the environment variables with the help of the following command “source

“:

<img

src=”https://linuxhint.com/wp-content/uploads/2020/09/install_apache_maven_ubuntu-15.png”

alt=”” />

Step 5: Check

Apache Maven version

Finally, check the version of Apache Maven you have installed on your Ubuntu 22.04: install apache maven ubuntu 16 How to uninstall Apache Maven from Ubuntu 22.04 Want to uninstall Apache Maven from Ubuntu 22.04

? If yes, use the following command:

install apache maven ubuntu 17

We have compiled the two simplest methods for installing Apache Maven on Ubuntu 22.04. Choose any of them according to your preferences.

Conclusion

For Apache Maven installation, you can use “apt” or the manual installation method. To use “apt”, open your Ubuntu 22.04 terminal and run the command “$ sudo apt install maven -y“. While you are in the manual installation, you need to download the archive file from the official website, extract it, and set the environment variables accordingly. This article discussed two methods for installing Apache Maven on Ubuntu 22.04.

Contact US