How to install Maven on Windows
While preparing this post, I’ve used below tools:
- JDK 1.8
- Maven 3.3.9
- Windows 8.1
1. JDK and JAVA_HOME
Make sure JDK is installed, and “JAVA_HOME” variable is added as Windows environment variable.
2. Download Apache Maven
Assume you unzip to this folder – C:\Program Files\apache-maven-3.3.9
3. Add M2_HOME and MAVEN_HOME
Add both M2_HOME and/or MAVEN_HOME variables in the Windows environment, and point it to your Maven folder.
For most of the situations, there is no need to add both M2_HOME and MAVEN_HOME together. But in some scenarios, some programs still reference Maven folder with MAVEN_HOME, so, it’s safer to add both.
For my specific reason, I didn’t add MAVEN_HOME. So it is up to you.
4. Add To PATH
Update PATH variable, append Maven bin folder –
so that you can run the Maven’s command everywhere.
Now, there are two ways to do this. The first one is, you can give your M2_HOME to your path as suggested in the element description. Or, you can just give your maven’ bin directory path (as a whole path) to your Path variable.
See below 2 screenshots:
After you finish, there is only one step left for us. Verifiying. You can do this by this little code part.
Open your command Prompt and run
You should see something like this:
C:\Program Files\Titus\Classification for Desktop>mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T18:41:47+03:00)
Maven home: C:\Program Files\apache-maven-3.3.9
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_121\jre
Default locale: en_US, platform encoding: Cp1254
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"