Windows

How to Install Apache Maven on Windows

In this tutorial, we will explore how we can quickly install and configure Apache Maven on Windows.
Captain Salem 3 min read
How to Install Apache Maven on Windows

Apache Maven is a popular open-source build automation tool used primarily for Java projects. It provides a standardized way to build and manage projects and dependencies, making it easier for developers to understand the state of a project, its structure, and its dependencies.

Check Prerequisites

The first step is to ensure that you have the Java JDK installed on your machine. This is because Maven requires JDK to be installed on your system.

To check whether you have JDK installed, open Command Prompt and type the following command:

java -version

The command above should return the installed JDK version. If the command returns no output or an error, you need to install the Java JDK on your machine.

You can check the resource below for that.

How to Install Java 11 on Windows: Step by Step
In this tutorial, we will see a detailed step by step guide on how to setup the Java JDK 11 on Windows using the Amazon Corretto JDK.

Download and Install Maven

The next step is to download and install Maven on the system.

Go to the Apache Maven official website's download page:

Maven – Download Apache Maven

Download the binary zip archive.

Once the download is complete, extract the zip file to a directory (for example, C:\Program Files\Apache\Maven). This path will be referred to as <MAVEN_HOME>.

Set Environment Variables

  1. Go to Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables.
  2. Click on "New" under System Variables. Then enter JAVA_HOME as Variable name and the path to your JDK installation as Variable value (for example, C:\Program Files\Java\jdk-11.0.2). Then click OK.
  3. Repeat the previous step to add a new System Variable named MAVEN_HOME with the path to your Maven installation (for example, C:\Program Files\Apache\Maven).
  4. Find the System Variable named Path and click on Edit. In the Variable value field, add ;%JAVA_HOME%\bin;%MAVEN_HOME%\bin at the end. Then click OK.

Once complete, open a new command prompt window and run the command:

mvn --version

f Maven is installed correctly, you will see information about the installed Maven version, the JVM version, and other details.

Install Maven Using Scoop

You can also install Maven using the Scoop package manager on your machine. You can run the command as shown:

scoop install maven

Output:

Installing 'maven' (3.9.2) [64bit] from main bucket
apache-maven-3.9.2-bin.zip (8.9 MB) [============================================================================] 100%
Checking hash of apache-maven-3.9.2-bin.zip ... ok.
Extracting apache-maven-3.9.2-bin.zip ... done.
Linking ~\scoop\apps\maven\current => ~\scoop\apps\maven\3.9.2
Persisting conf
Persisting lib\ext
'maven' (3.9.2) was installed successfully!
'maven' suggests installing 'java/openjdk'.

If you do not have Scoop installed, you can check the tutorial below:

How to Install Scoop on Windows
In this post, we will quickly go over how you can quickly install and configure Scoop package manager on Windows in easy steps.

Conclusion

That's it! You've successfully installed Maven on your Windows machine.

Share
Comments
More from GeekBits

Join us at GeekBits

Join our members and get a currated list of awesome articles each month.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to GeekBits.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.