15

I want to create a Tapestry Skeletion Project. I follow to these guide: http://maven.apache.org/download.html#Installation, http://juanjoefe.com/tutoriales/instalar-maven-en-windows-7/ and other guides on the internet.

But, when I type "mvn --version" or "mvn -version", I always receive error "mvn is not recognized as an internal or external command, operable program or batch file.

My friends use Windows 7 x86, and they had no problem. How can I install Maven 3.0.3 on Windows 7 x64?

Gia Duong Duc Minh
  • 1,319
  • 5
  • 15
  • 30
  • 2
    Did you add `%M2_HOME%/bin` to your `PATH` environment variable? That should be all you need to do, assuming that you installed everything else as per the instructions on that page. – aroth Aug 28 '11 at 07:40
  • having the same problem on my 64 bit windows 7: maven dir is in path, and i've restarted the system without any luck – Arsen Zahray Jan 16 '12 at 21:50

9 Answers9

22
  1. navigate to the Maven directory (e.g. in your explorer)
  2. go to a dir IN the bin
  3. copy the address in the address bar (F4 or CTRL+L, must end with bin)
  4. go to Start and type in env
  5. Select "edit the system evironment variables"
  6. find the PATH variable which must also have an existing value for Java as Maven needs Java.
  7. append a ; + paste the previously copied path.
  8. restart to update system
  9. run mvn install in the cli.

Yucca

Cadoiz
  • 1,446
  • 21
  • 31
thejartender
  • 9,339
  • 6
  • 34
  • 51
  • 17
    you do not need to restart the system .. just close all open command prompts and reopen them – aseychell Aug 28 '11 at 08:11
  • 1
    ? Care to elaborate? These are instructions to set your PATH permanently and there are NO command prompts open for this methodology. To my knowledge any interaction with the prompt is only kept for a session or until the prompt is closed. I am sure the user wants his mvn commands visible at each login without having to reconfigure the PATH each time? – thejartender Aug 28 '11 at 11:16
  • 5
    i was referring to step number 8. try changing your environment variables and just closing the cmd and reopening would result in the environment variables being refreshed for your new cmd sessions as well. – aseychell Aug 28 '11 at 15:35
  • Yes you do not need to restart Windows to update Path variables. Just start a new command line. Also answer with using path variables like MAVEN_HOME and adding them to path with %MAVEN_HOME% is a little bit more compact. – Igor Čordaš Apr 08 '14 at 11:47
17

Setting up Maven 3.0.4 in Windows 7 64 bit

  • Right Click My Computer → Properties → Advanced System Properties → Environment Variables → System Variables

  • Click "New"

  • Add

M2_HOME=C:\maven\apache-maven-3.0.4
M2=%M2_HOME%\bin

Assuming JAVA_HOME is already setup.

  • Edit Path environment variable and add %M2% as ;%M2% at the end of the existing path

Example:

C:\Users\arun.bc\oraclexe\app\oracle\product\10.2.0\server\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Dell\DW WLAN Card;C:\Ruby193\bin;C:\Borland\BCC55\Bin;%JAVA_HOME%/bin;%M2%

Apply and Close the System Properties

Open a new command prompt and type

mvn --version

The following message should be displayed:

C:\Users\arun.bc>mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
Maven home: C:\maven\apache-maven-3.0.4
Java version: 1.7.0_03, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_03\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Cadoiz
  • 1,446
  • 21
  • 31
Arun Chandrasekaran
  • 2,370
  • 2
  • 23
  • 33
  • Worked for me aswell! I am using it with Android Studio for compiling a Google CLoud app Engine project. – Fergers Sep 09 '13 at 08:15
  • Thank you I did know how to do all these steps but it was not working, then I found out in your example that you don't have ; at the end of the path so keep that in mind, last entry appended to path doesn't need ; – Igor Čordaš Apr 08 '14 at 11:48
  • This worked. I wonder, however, about why the order matters in this case: if `%M2% is not the last one, it would not work. – Treefish Zhang Mar 04 '17 at 22:54
3

I had the same issue but was able to fix it.

When I set up maven_home, I had a semi-colon ; at the end. So when I set up path it become MAVEN;\bin .... I removed the semi-colon ; at the end and problem solved.

For some reason the ; does not matter in Windows XP, but is a problem in Windows7 (32 bit).

Nathan

Leigh
  • 28,765
  • 10
  • 55
  • 103
nathan vo
  • 31
  • 1
  • Was this MAVEN;\bin added automatically or did you add it manually and make a mistake initially? ';' is a directory separator in Windowses, so XP must have found the mvn executable in some different way ... If maven install put it there, it sounds like a maven bug and ought to be reported or the bug report linked here. – jpe Jun 27 '12 at 15:59
2

You can also have multiple Maven installations in your PATH like I do:

C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\glassfish3\jdk7\bin;C:\DEV\servers\apache-tomcat-7.0.5\bin;C:\Program Files (x86)\Java\jdk1.6.0_25\bin;C:\DEV\apache-maven-3.0.3\bin;C:\DEV\apache-maven-2.2.1\bin;C:\Program Files (x86)\Windows Live\Shared 

The first Maven bin (Maven 3), is used before my previous (Maven 2).

thejartender
  • 9,339
  • 6
  • 34
  • 51
1

Windows sort all variables by alphabet. Don't use multiple elements to construct path to maven like M2 for folder /bin and M2_HOME for root folder JUST take full path to \bin directory of maven and put it in the Path variable

Henadzi Rabkin
  • 6,834
  • 3
  • 32
  • 39
1

You must add the directory containing the mvn executable to your PATH environment variable.

thejartender
  • 9,339
  • 6
  • 34
  • 51
Buhb
  • 7,088
  • 3
  • 24
  • 38
0
  1. Just set the system environment variable rather than user variable
  2. set the M2_HOME as: C:\Program Files\apache-maven-3.1.1 rather than : C:\Program Files\Apache Software Foundation\apache-maven-3.1.1 (I don't know why, but it seems that the space really matters!)
Frank Wang
  • 1,462
  • 3
  • 17
  • 39
0

I faced with this problem when use maven 3.3.3. Then tried with maven 3.3.9, it worked! Solution is download new version of maven.

Phuong
  • 1,153
  • 1
  • 10
  • 17
0

Solved my issue by doing the following:

  1. As per Maven [Install] section page, It says: "Extract distribution archive in any directory". So extracted files in G: drive and hence this was the cause root.

  2. Shifted the downloaded folder to C: drive solved my issue

  3. Updated environment variables. Closed and re-open the command prompt.

Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Suketa
  • 67
  • 11