How to Install Apache Maven on Windows, macOS, and Linux?
Last Updated : 17 Sep, 2024
Apache Maven is a comprehensive build automation tool widely used for managing and building Java projects. It simplifies the process of managing project dependencies and building projects through a standardized approach. This article provides step-by-step instructions to install Apache Maven on Windows, macOS, and Linux.
What is Maven?
Maven is a build automation tool that focuses on two main areas:
- Building Software: Maven uses a plugin-based architecture to manage the build process of software projects.
- Handling Dependencies: Maven automatically manages and downloads Java libraries needed for the project.
If you would like to install Apache Maven in operating systems such as Windows, macOS, or Linux, please take a look at the steps mentioned below.
Install Apache Maven on macOS
We need to follow the steps mentioned below to install apache maven in the macOS.
Step 1: Open Maven Website
First step is to open the maven website, simply type apache maven download in search engine and open the first website which will look similar to image below.
Step 2: Download the latest binary zip archive
Once you open the website, scroll and select the following file for downloading, this is the file that contains the apache maven for macOS.
Step 3: Extract the Zip File
Locate the downloaded zip file and double-click it to extract. It will create a new folder with the same name as the zip file.
Step 4: Open Environmental Path
Next step is to open the environmental path and for configuring the environment variable. We will have to open it in the terminal. For this, simply launch a terminal in macOS and type the following command to open the environmental path:
vi .zshenv
Step 5: Configure Environment Variable
Once we have opened the environmental path, we will have to configure it by adding the path where the maven folder is stored and update the BIN location (path and folder name can vary in your case).
Here is my location and path for example:
export M2_HOME="$PATH:/Users/prashantrana/Documents/Dev/JavaSpring/apache-maven-3.6.3"
export PATH=$PATH:$M2_HOME/bin
Once you save this location of the environmental path, maven is ready to be used in your macOS operating system.
After this, you can verify the installation by using the below command:
mvn -version
This will display the Maven version installed on your system. This is how apache maven can be installed and configured in macOS system.
Install Apache Maven on Windows
For installing apache maven on the Windows operating system, we already have a dedicated article that you can follow, it involves several steps for installing Apache Maven on Windows.
How to Install Apache Maven on Windows?
Install Apache Maven on Linux
For installing apache maven on Linux, we will have to follow the below steps one by one.
Step 1: Verify JDK Installation
First step is to verify whether JDK is installed or not. For this, simply open a terminal and type the following command:
java --version
After typing this command you can see output similar to image below, if it is not installed properly then it will show an error message that command was not found.
If you need to install JDK in Linux you can read this article: How to Install JDK in Linux?
Once it is verified that JDK is installed, go to the next step.
Step 2: Update Package Index
Next step is to update the library. This step is also important because we need to make sure we can run the command for installing maven and for that directory list needs to have maven in it.
Type the following command in your terminal and wait until the list is downloaded:
sudo apt update
Step 3: Install Maven
Next step is to install maven. For this, simply type the following command and it will install maven in the Linux system.
sudo apt install maven
As you can see in the image below as well:
Step 4: Verify Maven Installation
Once the installation is completed, we can check whether maven is installed successfully or not. For checking this, we will have to enter the following command in the linux terminal.
mvn -version
This will show us the maven version which is installed in the system, also seen in the image below as well.
This will display the Maven version installed on your system. This is how we can install maven in different operating systems.
Conclusion
Apache Maven is a robust tool for managing project builds and dependencies. Installing Maven varies by operating system, but the process is straightforward. Follow the steps outlined above for Windows, macOS, or Linux to get Maven up and running on your system.
Similar Reads
How to Install Apache Maven on Windows? Apache Maven is an automation tool. The tool is written in Java. It was initially released on 13 July 2004. It is developed by the Apache software foundation. It is part of the Jakarta Project. It is working on two aspects: how software is built, and its dependencies. It was created by Jason van Zyl
3 min read
How to Install Java on Windows, Linux and macOS? Java is a versatile programming language widely used for building applications. To start coding in Java, you first need to install the Java Development Kit (JDK) on your system. This article provides detailed steps for installing Java on Windows 7, 8, 10, 11, Linux Ubuntu, and macOS.Download and Ins
5 min read
How to Install Apache JMeter on Windows? The Apache JMeter⢠application is open-source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions. It can be used to simulate a heavy load on a
2 min read
How to Install Ruby on Rails on Windows and Linux? Ruby on Rails or just known as rails, is free and open-source software written in Ruby language under the MIT license. It is a server-side web application development framework, designed to make programming web applications easier by making assumptions about what every developer needs to get started
2 min read
How to Install Apache Tomcat on Windows? Apache Tomcat which is short for âTomcatâ is a free, open-source Java Servlet, Java Expression Language, JavaServer Pages, and WebSocket implementation. Tomcat is an HTTP web server that basically runs Java code in a âpure Javaâ environment. Here, we will see how to install Tomcat 10 on Windows 10 f
3 min read