'How to add Maven to the Path variable?
I have downloaded the maven 3.5.0 from here. I have set it in the path:
C:\apache-maven-3.5.0
Then i treid to add it to the path of Windows 7 as below:
Right click on my computer
Properties
Advanced System Setting
Environment Variable
New user variable and added
Maven_Homewith valueC:\apache-maven-3.5.0Add it to path variable with:
%Maven_Home%\binOpen
cmdand ask formvn -versionin desktop
Result:
It does not recognize maven
Solution 1:[1]
In windows:
Download the latest version of Maven from the http://maven.apache.org/ and Navigate to Use --> Download --> Download the Binary zip archive.
1) After the download, unzip the folder and copy it to the folder. (Lets say i have copied to c:\program files\apache-maven-3.52.
2) Setting the path of Maven in environment Variables: Search the Environment Variable --> Edit the System Environment variables--> Navigate to Advanced tab --> Environment Variables
i) MAVEN_HOME : Click New --> Variable Name : MAVEN_HOME , Variable Value: C:\Program Files\apache-maven-3.5.2
ii) M2_HOME : Click New --> Variable Name : M2_HOME , Variable Value: C:\Program Files\apache-maven-3.5.2
iii) Edit the 'Path' Environment Variable --> %M2_HOME%\bin
Testing whether Maven is installed: mvn -version
References:- http://www.baeldung.com/install-maven-on-windows-linux-mac
NOTE : In point iii don't forget to put semicolon(;) before and after.
Solution 2:[2]
- Open command console
- copy this set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH%
- cahnge the path accordingly
- click enter
it's all set and now check mvn -version
Solution 3:[3]
I had the same problem and fixed the issue by:
- Adding the M2_HOME to the USER VARIABLES
Adding the MAVEN_HOME to the USER VARIABLES
Adding the BIN folder to the PATH in the SYSTEM VARIABLES
(conform this video: https://www.youtube.com/watch?v=RfCWg5ay5B0)
Then i could run mvn -version in a NEW command terminal.
Solution 4:[4]
Adding
MAVEN_HOMEvariable (C:\Program Files\apache-maven-3.5.2) andM2_HOMEvariable (C:\Program Files\apache-maven-3.5.2\bin).- Add
%MAVEN_HOME%\binto the path in system variables . Then mvn -version in command prompt.
Solution 5:[5]
Make sure you download the Binary zip file from https://maven.apache.org/download.cgi. Then it should work fine by adding it to the path variable as mentioned in other answers. I've accidentally downloaded the src.zip file and of course it didn't work.

Solution 6:[6]
Additionally I would add this information that worked for me
After I opened the Environment Variables and followed these steps:
System variables > path > edit > add this one: C:\apache-maven-3.6.3\bin > ok button.
Also I would send my System variables you may need

I am using Windows 10
Solution 7:[7]
The changes in "System variables" requires system restart to take effect. ( The same for Linux systems also)
Solution 8:[8]
1) Make sure JDK is installed, and “JAVA_HOME” variable is added as Windows environment variable.
1) Download the Maven zip file, for example : apache-maven-3.5.0-bin.zip. Unzip it to the folder you want to install Maven. Assume you unzip to this folder – C:\Program Files\Apache\maven
3) Set the environment variables using system properties. Add M2_HOME, M2, MAVEN_OPTS to environment variables.
M2_HOME=C:\Program Files\Apache\maven\apache-maven-3.5.0
M2=%M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m
4) Now append M2 variable to System Path.
Append the string ;%M2% to the end of the system variable, Path.
5) Open Command Console and run this command c:\> mvn --version
you will get bellow output :
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.3.3
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_75\jre
Default locale: en_US, platform encoding: Cp1252
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alien |
| Solution 2 | user13054935 |
| Solution 3 | RobC |
| Solution 4 | grrigore |
| Solution 5 | Alex |
| Solution 6 | Mureinik |
| Solution 7 | m4rccc |
| Solution 8 |
