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_Home with value C:\apache-maven-3.5.0
Add it to path variable with: %Maven_Home%\bin
Open cmd and ask for mvn -version in desktop
Result:
It does not recognize maven
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.
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
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.
The problem get solved when i edit the path variable with ;%Maven_Home%\bin; so i should add the ; before and after it.
Adding
MAVEN_HOME variable (C:\Program Files\apache-maven-3.5.2) and M2_HOME variable (C:\Program Files\apache-maven-3.5.2\bin).
Add %MAVEN_HOME%\bin to the path in system variables .
Then mvn -version in command prompt.
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.
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
The changes in "System variables" requires system restart to take effect. ( The same for Linux systems also)
After doing changes, you need to reopen CMD window. In my case, my terminal window was opened before updating environment variables, and changes were not reflecting there i.e. mvn -version was returning "...not recognized as an internal or external command".
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
hello I can't seem to get mvn command working in command line
These are system variables
I have my path set as C:\Program Files\Apache\apache-maven-3.3.9\bin
and my Maven_Home set as
C:\Program Files\Apache\apache-maven-3.3.9
You should put maven in some location without any space in path. Except that everything looks fine. Take a look at this
I build a continuous integration system with Hudson+Maven+ SVN,When I build a job I get this error
While I use maven by command line, it succeed. the configuration of Hudson is below
the environment variable is set well
Hudson can't find the maven executables. You should point the MAVEN_HOME environment variable to the C:\YOUR_PATH_TO_MAVEN_DIRECTORY\bin directory and not to the installation directory itself.
I have installed Tomcat 7 on Windows 8, on which Jenkins is deployed. I configured the JDK, Ant and Maven in the Jenkin settings. In the Maven section, I gave a name as LocalMaven and the MAVEN_HOME as C:\Techie\apache-maven. When I did a test build, it gave me the following error that the mvn.bat is not recognized. Then I checked by entering mvn command in CMD. It gave some maven statements, which means maven is available in the PATH variables.
After googling, I changed the MAVEN_HOME as **%M2_HOME%\bin** in Jenkin-Maven configuration. Still it did not work.
LOG:
[workspace] $ cmd.exe /C '"mvn.bat -f HighScoresServiceClient compile && exit %%ERRORLEVEL%%"'
'mvn.bat' is not recognized as an internal or external command,
operable program or batch file
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
Edited: Added the analysis
The command executed by Jenkins is [workspace] $ cmd.exe /C '"mvn.bat -f String-replacer compile && exit %%ERRORLEVEL%%"' where mvn.bat is not a valid command and so Jenkins errors out as follows that 'mvn.bat' is not recognized as an internal or external command, I think Jenkins should call the command as mvn and not mvn.bat. Can some experts correct me if I am wrong? Please let me know how to change this behaviour if I am right.
Edited: Attached the Configuration
I suppose your Tomcat server is running as a Windows service.
Did you create your MAVEN_HOME and M2_HOME as system environment variables? (idem for your PATH)
Another solution is to configure your variables in the apache-tomcat/bin/setenv.bat file:
set MAVEN_HOME=C:\Techie\apache-maven
set PATH=%MAVEN_HOME%\bin;%PATH%
I bet you've installed Maven 3.3 that has mvn.bat renamed to mvn.cmd
There is a report on this issue in Jenkins JIRA: https://issues.jenkins-ci.org/browse/JENKINS-27525
I have some problems with my maven 3 installation.
I have downloaded maven 3.0.3 and extracted it to a folder.
I set the following environment variables.
M2_HOME: C:\a few folders\apache-maven-3.0.3
M2: %M2_HOME%\bin
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_25
Path: %JAVA_HOME%\bin; %M2%
I get a message that the command is not recognized when i type "mvn" in the command line. Any ideas?
Maven 3.0.3 and later doesn't need the M2_HOME variable.
The following environment variable changes are sufficient to run Maven from the command-line:
Setting JAVA_HOME to the Java jdk directory (eg. C:\Program Files\Java\jdk1.6.0_29)
Setting PATH to include the Maven bin directory.
Everything looks OK.
I don't know if there should be a space after the semicolon and %M2%. This might be your problem.
Make sure you typed a "a few folders" correctly.
Try this:
Add(create) these new variables at the SYSTEM VARIABLES (M3_HOME and M3):
M3_HOME: C:\maven_installation_folder\
M3: %M3_HOME%\bin
Include at: "CLASSPATH" and "Path" variables
CLASSPATH: other_variables;%M3%;
Path: other_variables;%M3%;
Go to Command Prompt (cmd) and type:
mvn -version
Maven 3.0.3 and later doesn't need the M2_HOME variable. So no need to add that.
I did the following in the Windows System variables and it works:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
Path=C:\Program Files\Java\jdk1.8.0_31\bin;C:\Selenium 3\Maven\apache-maven-3.3.3\bin