Development

How to Install Maven on Windows

Captain Salem 2 min read

How to Install 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.

In this tutorial, we will explore how we can quickly install and configure Apache Maven on Windows.

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.

https://www.geekbits.io/how-to-install-java-11-on-windows-step-by-step/

Download and Install Maven

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

  1. Go to the Apache Maven official website’s download page: https://maven.apache.org/download.cgi
  2. 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>.

Download the binary zip archive.

image-20230520150253788
image-20230520150253788

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:

https://www.geekbits.io/how-to-install-scoop-on-windows/

Conclusion

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

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

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

Success! Your billing info has been updated.

Your billing was not updated.