Apache Maven: How to Download and Install the Latest Version
Introduction
Apache Maven is a software project management and comprehension tool that can help you with building, testing, documenting, and deploying your Java applications. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
download maven
If you think that Maven could help your project, you can find out more information in the section of the official website. This includes an in-depth description of what Maven is and a list of some of its main features.
In this article, I will show you how to install Apache Maven on a system running Windows, Linux, or Mac. I will also explain some of the benefits and alternatives of using Maven for your Java projects. Let's get started!
Installing Maven on Windows
To install Maven on Windows, you need to have a JDK installation on your system. Either set the JAVA_HOME environment variable pointing to your JDK installation or have the java executable on your PATH. You also need a working Internet connection and access to an account with administrator privileges.
Follow the steps outlined below to install Apache Maven on Windows.
Downloading and extracting Maven zip file
Visit the and download the version of Maven you want to install. The Files section contains the archives of the latest version. Access earlier versions using the archives link in the Previous Releases section.
Click on the appropriate link to download the binary zip archive of the latest version of Maven. As of the time of writing this article, that is version 3.8.4.
Since there is no installation process, extract the Maven archive to a directory of your choice once the download is complete. For this article, we are using C:\Program Files\Maven\apache-maven-3.8.4.
Adding MAVEN_HOME system variable
Open the Start menu and search for environment variables.
Click the Edit the system environment variables result.
Under the Advanced tab in the System Properties window, click Environment Variables.
Click the New button under the System variables section to add a new system environment variable.
Enter MAVEN_HOME as the variable name and the path to the Maven directory as the variable value. Click OK to save the new system variable.
Adding MAVEN_HOME directory in PATH variable
Select the Path variable under the System variables section in the Environment Variables window. Click the Edit button to edit the variable.
Click the New button in the Edit environment variable window.
Enter %MAVEN_HOME%\bin in the new field. Click OK to save changes to the Path variable.
Note: Not adding the path to the Maven home directory to the Path variable causes the 'mvn' is not recognized as an internal or external command, operable program or batch file error when using the mvn command.
Click OK in the Environment Variables window to save the changes to the system variables.</li Verifying Maven installation
Open a new command prompt window and type the following command: mvn -version
If Maven is installed correctly, you should see the output similar to the following:
C:\Users\user>mvn -version Apache Maven 3.8.4 (9b656c72d54e8b9a9a9e0a3d1f7c8cf1ac168a66) Maven home: C:\Program Files\Maven\apache-maven-3.8.4 Java version: 17.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-17.0.1 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Congratulations! You have successfully installed Maven on Windows.
How to download and install Apache Maven on Windows
Download Maven for Mac OS X
Maven download and setup tutorial
Download Maven binaries and sources
Maven download link and checksums
How to verify Maven download with signature
Download Maven plugins and shared libraries
Maven download archive and release history
How to download Maven dependencies
Maven download mirror sites and repositories
Download Maven Eclipse plugin
Download Maven IntelliJ IDEA plugin
Download Maven NetBeans plugin
Download Maven command-line tool (mvn)
Download Maven documentation and guides
Download Maven project templates (archetypes)
Download Maven settings.xml file
Download Maven pom.xml file
Download Maven wrapper script (mvnw)
Download Maven Docker image
Download Maven Spring Boot starter
Download Maven Quarkus extension
Download Maven Micronaut framework
Download Maven Helidon toolkit
Download Maven Jakarta EE specification
Download Maven JUnit testing library
Download Maven TestNG testing framework
Download Maven Selenium WebDriver
Download Maven Cucumber BDD tool
Download Maven Rest Assured API testing library
Download Maven JMeter performance testing tool
Download Maven SonarQube code quality analysis tool
Download Maven JaCoCo code coverage tool
Download Maven SpotBugs bug detection tool
Download Maven PMD static code analysis tool
Download Maven Checkstyle code style checker tool
Download Maven FindBugs bug finding tool
Download Maven Lombok annotation processor tool
Download Maven Log4j logging framework
Download Maven SLF4J logging facade
Download Maven Apache Commons libraries
Download Maven Google Guava libraries
Download Maven Jackson JSON parser library
Download Maven Gson JSON serializer library
Download Maven Apache HttpClient library
Download Maven OkHttp library
Download Maven Retrofit library
Download Maven Feign library
Installing Maven on Linux
To install Maven on Linux, you need to have a JDK installation on your system. Either set the JAVA_HOME environment variable pointing to your JDK installation or have the java executable on your PATH. You also need a working Internet connection and access to an account with sudo privileges.
Follow the steps outlined below to install Apache Maven on Linux.
Downloading and extracting Maven tar.gz file
Open a terminal window and navigate to the directory where you want to download Maven. For this article, we are using /opt/maven.
Create the directory if it does not exist and change its ownership to your user account using the following commands:
sudo mkdir /opt/maven sudo chown -R $USER:$USER /opt/maven
Visit the and copy the link of the binary tar.gz archive of the latest version of Maven.
Use the wget command to download the archive file to the /opt/maven directory using the copied link. For example:
wget -P /opt/maven
Extract the archive file using the tar command:
tar xvf /opt/maven/apache-maven-3.8.4-bin.tar.gz
Adding Maven bin directory to PATH variable
Edit your /.bashrc file using your preferred text editor and add the following lines at the end of the file:
# Maven settings export M2_HOME=/opt/maven/apache-maven-3.8.4 export MAVEN_HOME=$M2_HOME export PATH=$M2_HOME/bin:$PATH
Note: The M2_HOME variable is deprecated and not required by Maven 3.x, but some third-party tools and scripts may still refer to it.
Save and close the file, then reload it using the following command:
source /.bashrc
Verifying Maven installation
Type the following command in your terminal window: mvn -version
If Maven is installed correctly, you should see the output similar to the following:
$ mvn -version Apache Maven 3.8.4 (9b656c72d54e8b9a9a9e0a3d1f7c8cf1ac168a66) Maven home: /opt/maven/apache-maven-3.8.4 Java version: 17.0.1, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-17-oracle Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.11.0-40-generic", arch: "amd64", family: "unix"
Congratulations! You have successfully installed Maven on Linux.
Installing Maven on Mac
To install Maven on Mac, you need to have a JDK installation on your system. Either set the JAVA_HOME environment variable pointing to your JDK installation or have the java executable on your PATH. You also need a working Internet connection and access to an account with administrator privileges.
One of the easiest ways to install Maven on Mac is to use Homebrew, a package manager for macOS. If you don't have Homebrew installed, you can follow the instructions on the to install it.
Follow the steps outlined below to install Apache Maven on Mac using Homebrew.
Downloading and installing Homebrew
Open a terminal window and run the following command to download and install Homebrew:
/bin/bash -c "$(curl -fsSL
Enter your password when prompted and wait for the installation to complete.
Verify that Homebrew is installed correctly by running the following command:
brew --version
You should see the output similar to the following:
$ brew --version Homebrew 3.3.9 Homebrew/homebrew-core (git revision 0f9c6a8b7b; last commit 2021-12-14) Homebrew/homebrew-cask (git revision 0f9c6a8b7b; last commit 2021-12-14)
Installing Maven with Homebrew
Run the following command to install Maven usi