Java Questions
Java Questions

Reputation: 7953

'mvn' is not recognized as an internal or external command,

I get the following error when I type the command mvn --version:

'mvn' is not recognized as an internal or external command, operable program or batch file.

I have also followed this but still I am unable to get the work done.

when I type this command echo %M2_HOME% I get path printed as D:\Program Files\apache-maven-3.0.4 when I type 'echo %M2%' I get the path printed as D:\Program Files\apache-maven-3.0.4\bin

Environment : Windows XP

Upvotes: 44

Views: 160455

Answers (4)

Eunhae Hwang
Eunhae Hwang

Reputation: 1

This is how I fixed the 'java' is not recognized in cmd and 'mvn' is not recognized in cmd and 'JAVA_HOME environment variable is not defined correctly.'

I assumed that I had maven in my computer, but I was wrong. I must have done with my previous downloaded maven. So, I download maven again. I checked my java location, too. Then, 'mvn' is recognized, but JAVA_HOME environment variable is not defined correctly. When I put the full location of maven, my terminal recognized mvn command. Then, I could do the mvn clean install command. enter image description here enter image description here These are my local computer Environment Variables. Please look at Path in User variables for my local computer. This Path is for java. Then, look at PATH in System variable. This PATH is for maven. Last, please look at System variables. JAVA_HOME Value does not end with bin. I put jre instead of bin or nothing as someone wrote on the internet. That person does not why this way works, though. M2 Value is copied from the internet suggestion. M2_HOME is the location of maven in my local computer.

Upvotes: 0

wulfgarpro
wulfgarpro

Reputation: 6924

On my Windows 7 machine I have the following environment variables:

  • JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07

  • M2_HOME=C:\apache-maven-3.0.3

On my PATH variable, I have (among others) the following:

  • %JAVA_HOME%\bin;%M2_HOME%\bin

I tried doing what you've done with %M2% having the nested %M2_HOME% and it also works.

Upvotes: 40

Jaanus
Jaanus

Reputation: 16531

Add maven directory /bin to System variables under the name Path.

To check this, you can echo %PATH%

Upvotes: 12

kirschmichel
kirschmichel

Reputation: 923

Make sure you have your maven bin directory in the path and the JAVA_HOME property set

Upvotes: 27

Related Questions