How to add Maven to the Path variable?

我的梦境 提交于 2020-01-14 07:30:48

问题


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:

  1. Right click on my computer

  2. Properties

  3. Advanced System Setting

  4. Environment Variable

  5. New user variable and added Maven_Home with value C:\apache-maven-3.5.0

  6. Add it to path variable with: %Maven_Home%\bin

  7. Open cmd and ask for mvn -version in desktop

Result:

It does not recognize maven


回答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.




回答2:


The problem get solved when i edit the path variable with ;%Maven_Home%\bin; so i should add the ; before and after it.




回答3:


Adding

  1. MAVEN_HOME variable (C:\Program Files\apache-maven-3.5.2) and M2_HOME variable (C:\Program Files\apache-maven-3.5.2\bin).
  2. Add %MAVEN_HOME%\bin to the path in system variables . Then mvn -version in command prompt.



回答4:


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


来源:https://stackoverflow.com/questions/45119595/how-to-add-maven-to-the-path-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!