How to Install Apache Maven on Windows, macOS, and Linux?
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.
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.