In this tutorial, we will explore how we can quickly install and configure 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.
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:
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.
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:
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
Set Environment Variables
- Go to Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables.
- Click on "New" under System Variables. Then enter
JAVA_HOMEas 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.
- Repeat the previous step to add a new System Variable named
MAVEN_HOMEwith the path to your Maven installation (for example,
- Find the System Variable named
Pathand click on Edit. In the Variable value field, add
;%JAVA_HOME%\bin;%MAVEN_HOME%\binat the end. Then click OK.
Once complete, open a new command prompt window and run the command:
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
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:
That's it! You've successfully installed Maven on your Windows machine.