0

I am trying to install maven v3.5.4 onto my computer and whenever I try the 'mvn -version' command, I get

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

I have looked up multiple tutorials on how to do this, and they are giving nearly the same information. Add system variables M2 and M2_HOME, then append a directory to the Path system variable. I have the System Variables configured to the following:

M2:

  • Name: M2
  • Value: C:\Program Files\Apache\maven\bin

M2_HOME:

  • Name: M2_HOME
  • Value: C:\Program Files\Apache\maven

MAVEN_HOME:

  • Name: MAVEN_HOME
  • Value: C:\Program Files\Apache\maven

Path:

  • Name: Path
  • Value: %M2_HOME%\bin;%JAVA_HOME%\bin

I have seen people saying that there should be a .exe or .bat file inside the bin directory. I do not have any of these. I only have 4 files inside this folder. Maven bin directory

This could perhaps be the issue. The path to my Maven directory is: Maven Folder Path I have the following maven related system variables:

System Variables

And my Path variable is:

Path Variable

I'm not sure how to fix this issue so if anyone knows, please let me know.

Nitin Bisht
  • 5,053
  • 4
  • 14
  • 26
Plasma
  • 43
  • 1
  • 10
  • 1
    `%M2_HOME%\bin %JAVA_HOME%\bin` ?? is it by mistake or missing `;` – Shubhendu Pramanik Jul 31 '18 at 05:59
  • By mistake, meant to put a ; I'll fix that – Plasma Jul 31 '18 at 05:59
  • have you added your `JAVA_HOME` variable linked to your jdk directory? Also you should setup `MAVEN_HOME` with value `C:\Program Files\Apache\maven` to avoid troubles. – Mochuelo Jul 31 '18 at 06:02
  • Yes, JAVA_HOME is added as a System Variable. I tried adding MAVEN_HOME and testing the mvn command still gives the error. – Plasma Jul 31 '18 at 06:07
  • Can you navigate into your maven/bin folder and type "mvn --version"? – T A Jul 31 '18 at 06:34
  • @Plasma There is no .exe or .bat file in my '/bin' folder. I am using version 3.5.4 like you. The bin folder looks fine. I'm confident that a fresh installation of Maven will fix your problem. If this doesn't work either, try restarting your computer too. – Soutzikevich Jul 31 '18 at 08:05
  • @TA I tried navigating there and I'm still getting the same error. – Plasma Aug 01 '18 at 20:49
  • @P.Soutzikevich I restarted my computer after a fresh installation and it still doesn't seem to be working. – Plasma Aug 01 '18 at 20:55
  • in all of this, are you closing the command line after you do some changes to the PATH? The new changes for system variables are not beeing reflected to the console until you restart it. – Ermal Nov 23 '19 at 10:38

3 Answers3

2

Add a variable MAVEN_HOME like:

Name: MAVEN_HOME

Value: C:\Program Files\apache-maven-3.3.9\bin

In your case, the M2_HOME path is not correct. Hence It must not be working. Try to give the correct path to the bin folder.

Nitin Bisht
  • 5,053
  • 4
  • 14
  • 26
0

First you have to download maven from here, preferably the latest version and install it.

Then, you have to set the Path variable for Maven.

Go to Start and search for 'Edit the system environment variables'. Choose the environment variables option and like you do in the example you provided, leave M2_HOME as you have it, delete M2 and change the one in your path to: %M2_HOME%\bin\;

Also, please make sure that you are editing the system environment variables.

As I it says on the download page of the version you are trying to install: "Maven 3.3+ require JDK 1.7 or above to execute". So make sure you have the right version of java.

If this does not work, then I don't think someone on Stack-Overflow can help.

Soutzikevich
  • 991
  • 3
  • 13
  • 29
  • I have done this and it doesn't seem to be working. And yes I am editting System environment variables and not User variables. – Plasma Jul 31 '18 at 06:17
  • Have you tried uninstalling and reinstalling maven? If you are using Windows, then use this [link](http://www-eu.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip). It's the current stable version. – Soutzikevich Jul 31 '18 at 07:57
  • @Plasma I have updated my answer. The problem might be the version of Java you are using. You need java 7 or later – Soutzikevich Jul 31 '18 at 08:02
  • I'm using Java 8 and I tried uninstalling and reinstalling maven using your link and I am still getting the same error. – Plasma Aug 01 '18 at 20:47
0

Install Java

  1. Download Java SE Development Kit from Oracle's website and install it
  2. Browse via windows search to Environment Variables
  3. Press New... in System variables list
  4. Insert JAVA_HOME to Variable name
  5. Insert its path to Variable value (e.g: C:\Program Files\Java\jdk1.8.0_102)
  6. Press Edit to Path and then press New
  7. Insert %JAVA_HOME%\bin
  8. Open cmd and type java -version to check if it is ok

Install Maven

  1. Download Maven Binary zip archive from Apaches's website
  2. Unzip the folder and move it to C:\Program Files
  3. Browse via windows search to Environment Variables
  4. Press New... in System variables list
  5. Insert MAVEN_HOME to Variable name
  6. Insert its path to Variable value (e.g: C:\Program Files\apache-maven-3.6.2)
  7. Press Edit to Path and then press New
  8. Insert %MAVEN_HOME%\bin
  9. Open cmd and type mvn -version to check if it is ok
CodeSlave
  • 425
  • 6
  • 21