Maria1995
Maria1995

Reputation: 501

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

I have installed maven on my pc and if I type "mvn --version" in the cmd, I get:

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T14:57:37+03:00)
Maven home: C:\Users\mmmm\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3
Java version: 1.8.0_251, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_251\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

The problem is that from Intellij, if I try to do a mvn clean install from the terminal, I get "'mvn' is not recognized as an internal or external command, operable program or batch file."

My system variables contain these:

M2_HOME = C:\Users\mmmm\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3
M2 = %M2_HOME%\bin
Path = %M2_HOME%\bin

How can I fix this?

Upvotes: 14

Views: 65507

Answers (5)

Mitali Padiya
Mitali Padiya

Reputation: 9

  1. Create an environment variable M2_HOME - C:\Program Files\apache-maven-3.9.6
  2. Add %M2_HOME%\bin to PATH
  3. Restart intelliJ

Upvotes: -1

王林涛
王林涛

Reputation: 11

restart your computer and then idea will update the system enviroment variables; enter image description here

Upvotes: 1

user18672350
user18672350

Reputation: 49

Had a similar issue, solved by just restarting intelliJ

Upvotes: -1

sankar
sankar

Reputation: 340

I had a similar issue that was fixed after I pointed M2_HOME to Intellij's maven plugin path instead of pointing to a path associated with a separate maven installation.

"C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\plugins\maven\lib\maven3"

I also added %M2_HOME%\bin to PATH.

Upvotes: 1

Jess
Jess

Reputation: 3715

I have also installed JDK 1.8 and Maven3 as below:

>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

>javac -version
javac 1.8.0_121

>mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\SDK\maven\apache-maven-3.6.3\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation, runtime: C:\java\jdk1.8\jre
Default locale: en_US, platform encoding: MS932
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

I found the problem is the environment variables of terminal: enter image description here

Copy your bin path of JDK and Maven into it!! And then restart your Terminal.

enter image description here

Upvotes: 17

Related Questions