How To Install Maven On Linux?
Last Updated :
05 Mar, 2024
Maven is your software program development sidekick! Maven, crafted using the Apache Software Foundation, is the go-to device for simplifying the complex international of build automation and task management. It's designed to permit you to be conscious of coding while effortlessly managing obligations like constructing, checking out, and deploying initiatives.
Think of Maven as your task agency wizard. With its XML-based configuration, Maven makes mission management a breeze, thanks to the usage of conventions that assist you in diving instantly into improvement without getting slowed down through construction process intricacies.
Steps to install Maven on Linux
Note: We are installing Maven on Ubuntu Linux (20.04 LTS)
Step 1: Update local packages
- sudo apt update: This command is used to update the local package index on your machine.
- sudo apt upgrade: This command is used to upgrade the installed packages on your system to the latest available versions.
sudo apt update && sudo apt upgrade -y
Step 2: Install JDK
Since Maven is primarily built using Java. Install JDK. You need the Java Development Kit (JDK) in addition to the JRE in order to compile and run Java-based software. To install the JDK, execute the following command, which will also install the JRE:
sudo apt install openjdk-11-jdk

Step 3: Verify Installation
java --version

Step 4: Install Maven.
sudo apt install maven -y

Step 5: Verify Installation
mvn --version

Manual Installation
Step 1: This command is used to update the local package index on your machine.
sudo apt update

Step 2: Since Maven is primarily built using Java. Install JDK. You need the Java Development Kit (JDK) in addition to the JRE in order to compile and run Java-based software. To install the JDK, execute the following command, which will also install the JRE:
sudo apt install default-jdk
Step 3: Installing the java on linux machine

sudo wget http://www-eu.apache.org/dist/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz

Step 4: Extracting the maven on linux
sudo tar -zxvf apache-maven-3.5.3-bin.tar.gz

Step 5: Move the extracted Maven directory to the desired location. Example, we move it to /opt/:
sudo mv apache-maven-3.5.3 /opt/maven

Step 6: The command nano ~/.bashrc
is used to open and edit the user-specific Bash configuration file.
nano ~/.bashrc

Step 7: Add following to /.bashrc
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Step 8: The command source ~/.bashrc
is used to apply the changes made in the ~/.bashrc
file immediately to the current Bash session.
source ~/.bashrc

Step 9: Verify Installation
mvn --version

Similar Reads
How to Install MySQL on Linux?
MySQL is an open-source relational database management system that is based on SQL queries. Here, "My" represents the name of the co-founder Michael Widenius's daughter and "SQL" represents the Structured Query Language. MySQL is used for data operations like querying, filtering, sorting, grouping,
3 min read
How to Install Tor on Linux?
Tor browser is a web browser that is designed and developed to protect your privacy online and is mostly famous among normal people as a key for safely accessing hidden or restricted online resources, including those on the dark web. We will see what Tor is and how to install it on your Linux machin
5 min read
How to Install Minecraft on Linux ?
Minecraft is one of the most popular sandbox video games developed by Mojang, originally created by Markus "Notch" Persson using the Java programming language. If you're an experienced gamer or new to the Minecraft world, playing it on Linux is easy with the right instructions. Here, we will walk yo
3 min read
How to Install LISP on Linux?
LISP (List programming) is the second-oldest high-level programming language after Fortran. It has a fully parenthesized prefix notation. Installing LISP on Linux:Follow the below steps to install LISP on Linux: Step 1: Install SBCL compiler. Steel Bank Common Lisp (SBCL) is the most common Lisp com
1 min read
How to Install Node.js on Linux
Installing Node.js on a Linux-based operating system can vary slightly depending on your distribution. This guide will walk you through various methods to install Node.js and npm (Node Package Manager) on Linux, whether using Ubuntu, Debian, or other distributions.PrerequisitesA Linux System: such a
6 min read
How to Install Netbeans on a Linux
NetBeans is an open-source Integrated Development Environment (IDE) primarily for Java programming, but it also supports various other programming languages. It is used to develop mobile applications, desktop applications, and web applications. This guide will help you install NetBeans on a Linux sy
4 min read
How to Install PHP on Linux?
PHP is a popular server-side scripting language that is especially used in web development. If you're working on a Linux environment, whether it's a personal development setup or a production server, you will likely need PHP installed. In this article, we will see the step-by-step guide to install P
2 min read
How to Install Kotlin on MacOS?
Kotlin is an open-source programming language. It is developed by JetBrains and is designed to be a modern, safe, and efficient language for building modern applications. It is a functional language means it is based on the functional paradigm. It is a compiled language, which means it compiled to b
4 min read
How to Install LISP on MacOS?
Lisp is one of the oldest programming languages. It was invented back in the 1950s by John McCarthy. Lisp is a so-called meta-programming language or a symbolic programming language. It can be used for any sort of task. It's a general-purpose language. It is the second-oldest high-level programming
2 min read
How To Install Splunk on Linux
Splunk is a software that helps organizations work with large amounts of data. The latest version 9.0.4.1 has new abilities. It can search data faster and use less memory. This makes it easier to look at and understand the data. Splunk 9.0.4.1 can now store old data in the cloud. This frees up space
5 min read