Article

Installing Apache Maven on Windows 10 from powershell

To install Apache Maven on Windows 10, you only need to perform 3 steps:
  1. download the Maven’s zip file
  2. Unzip it to the directory you wish to install
  3. configure the Windows environment variables

Prerequisite

Ensure Java JDK 1.8 is installed, and “JAVA_HOME” is setup as an environment variable. I use powershell as my command line. Check which version of the compiler you have installed withIf you get nothing or something less than 8.0, head over to Oracle and get the newest JDK8 installer and install it. You will want the latest “Java SE Development Kit 8uxxx”.Next, ensure JAVA_HOME environmental variable is set and at the version you would expectjdk1.8 is what you want (default installs are named after the version number, you’ve got more work to do if that’s not the case for you). If not, set your environmental variable to the proper path with an elevated powershell session (in the start menu, type Powershell and hit [CTRL] + [SHIFT] + [ENTER]):Using the .NET Framework’s System.Environment class and the SetEnvironmentVariable method, we are passing three parameters:
  • “JAVA_HOME”, the name of the environmental variable
  • “C:\Program Files\Java\jdk1.8.0_152”, the path to the JDK
  • “Machine” , which makes JAVA_HOME a machine-level environment variable

Step 1 — download and verify

Download the newest version of Apache Maven. Get the Binary zip archive. Ensure your download is valid with the MD5 checksum (also on the download page). In this HOWTO, my path to downloads is C:\users\paul\OneDrive\Downloads\Open an elevated powershell session (in the start menu, type Powershell and hit CTRL + SHIFT + ENTER) and then:The hash value on line 5 should match the hash on the download page. Delete and re-download if not.

Step 2 — unzip for installation

I install Maven to the Java folder (keeping all this stuff in the same location makes sense to me) and expand (unzip) the file:That’s it! You have installed it.

Step 3 — setup environmental variables

Add maven variables (MAVEN_HOME and M2_HOME)

Alter your PATH variable too:

troubleshooting, verifying installation

Since these changes don’t affect the current session, start a new powershell session (elevated or not) and check the environmental variables again for accuracy:Next, ensure Maven is configured for command line use with the command “mvn -version”:You’re ready to go!

Comments Closed.