Install Maven on Windows 10

Prerequisites

Before install Maven on Windows 10, make sure Java is already installed.

Download Maven

Go to the official download page, at the URL https://maven.apache.org/download.cgi

The first highlighted line says that the default mirror is http://apache.panu.it/, but we can choose another one from the highlighted dropdown menù and click the “Change” button to confirm.
In the same page, after the “System Requirements” paragraph, look at the “Files” section. Here, you can download the binary file from the “Binary zip archive” line.

Install Maven on Windows 10

Install Maven on Windows 10

Unzip apache-maven-3.6.3-bin.zip in C:\Program Files

Install Maven on Windows 10

Inside the unzipped folder, there is a structure like the following

Install Maven on Windows 10

That’s all, installation process is now complete, congratulation!
To check installation, go to \bin folder containing mvn.cmd, open the command prompt and type the following maven command:

C:\Program Files\apache-maven-3.6.3\bin>mvn -version

It should print out your installed version of Maven and other informations:

Install Maven on Windows 10

Add MAVEN_HOME Environment Variable

Even if Maven is installed, to be able to use its commands from anywhere on the computer (and not just from the \bin folder as seen in the previous paragraph), we need to add its environment variable. Type “environment variables” from Window search box.

Install Maven on Windows 10

and click on “Edit the system environment variables” .
The “System Properties” window will appear.

Install Maven on Windows 10

Click the “Environment Variables…” button from “Advanced” tab.
At this point, we have to choose if

  • add an environment variable valid for all system users
  • or add an environment variable valid only for your account

We choose the second option: click the “New…” button from “User variables for <yournameaccount> …” section to open “Edit User Variable” window.
Insert MAVEN_HOME in the “Variable name field. Then, insert the folder’s path where we unzipped the binary file downloaded in the previous paragraph (C: \ Program Files \ apache-maven-3.6.3).

Finally click “OK” for all opened windows

Add %MAVEN_HOME%\bin to Path

What we did in the previous paragraph, was only a preliminary step, but we still can’t use Maven commands outside installation folder. All we did was only create this assignment in the system:

MAVEN_HOME=C:\Program Files\apache-maven-3.6.3

If we want to use Maven commands from anywhere on the File System, we have to add C:\Program Files\apache-maven-3.6.3\bin path to the Windows Path variable.

Open “Environment Variables” window as done in the previous paragraph.
We have to choose if

  • Edit Path Environment Variable to all system accounts. In this case any Windows 10 user can use Maven commands.
  • Edit Path Environment Variable to our account. In this case only this Windows 10 user can use Maven commands.

We choose second option, following this steps

  1. Double click on Path variable from “User variables for <yournameaccount> …”
  2. Click “New…” button at the top-right of “Edit environment variable” window.
  3. Insert %MAVEN_HOME%\bin at list bottom.

Finally click “OK” for all opened windows.
Now we should be able to use Maven commands from any folder.
So, we can try to check Maven version from a differtent folder, for example from C:\Users

Precedente Why is Java a portable language? Successivo Apache Ant Beginners Tutorial