mvn not recognized as an internal or external command error

+2 votes
I am trying to install maven on windows. I have downloaded the apache mavenbin.zip and extracted it on my C:\Program Files\apache-maven-3.6.1. I already have jdk 1.8 installed in my system and also have configured the JAVA_HOME and MAVEN_HOME environment variables via the system properties.I have also ensured that i have added their respective bin locations on the PATH variable. Still i am encountering the above error. Kindly help!
Jun 3, 2019 in DevOps Tools by Namik
• 1,230 points
95,218 views

3 answers to this question.

+1 vote

Setting the environment variables JAVA_HOME, MAVEN_HOME and  PATH  via the system property settings may not be effective sometimes.In the command prompt, echo %JAVA_HOME% ,%MAVEN_HOME%, %PATH% and check the values if they are correctly set and included in the PATH as well. if not, you need to set those Environment variables via the command prompt using the following command:

setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_211"

setx PATH "%PATH%;%JAVA_HOME%\bin";

same for MAVEN_HOME as well.

setx MAVEN_HOME "C:\Program Files\apache-maven-3.6.1"

setx PATH "%PATH%;%MAVEN_HOME%\bin";

You can check if these are set appropriately by running the commands:  java -version and mvn --version on the command prompt.

answered Jun 3, 2019 by Sirajul
• 59,230 points
setx cammand not recognizing
What's your current PATH variable contents? At minimum, ensure C:\windows\system32 isn't missing from it..
I have done these all Still not working I fount This Problem

cd C:\Program Files\Java; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_111\\jre" "M2_HOME=C:\\Program Files\\apache-maven-3.6.3" cmd /c "\"\"C:\\Program Files\\apache-maven-3.6.3\\bin\\mvn.bat\" -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=webapp-javaee6 -DarchetypeVersion=1.5 -DarchetypeRepository=http://repo.maven.apache.org/maven2 -DgroupId=com.pro -DartifactId=mavenproject1 -Dversion=1.0-SNAPSHOT -Dpackage=com.pro.mavenproject1 -Dbasedir=\"C:\\Program Files\\Java\" -Darchetype.interactive=false -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven-nblib\\netbeans-eventspy.jar\" --batch-mode archetype:generate\""

I have set all environment variable properly,In fact when I try to check the Java version and maven version on cmd prompt. It shows appropriately, But when I try to run maven web app from jenkins it gives below error..Why is that hapening ? 

C:\Program Files (x86)\Jenkins\workspace\mvn_web_app>mvn package 
'mvn' is not recognized as an internal or external command,
operable program or batch file.
It seems you have not set the path for System variables. That is why it is not working from another folder. Check once in your environment variable.
0 votes
Build maven in folder where maven is kept and then run - mvn --version..it should run.
answered Aug 1, 2020 by Visha
Hi @Visha, thank you for your contribution to the Edureka Community.

Register/Sign up on the community to gain points for further contributions. You may ask questions, answer, upvote, and downvote an answer. Each of these would fetch you points and you could be among the top contributors and win exciting merchandise from Edureka.

Cheers!

I am found error like that

C:\Users\HP>mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files (x86)\apache-maven-3.6.3\bin\..
Java version: 14.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-14.0.2
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
'cmd' is not recognized as an internal or external command,
operable program or batch file.

Hi@Ankush,

Your command was successfully run. That's why you can see the details. But it should not show the last line. Check your system environment variable once and restart your command line.

Hey @Ankush, could you please post this as a separate query?
0 votes
Hi,

You need to set the environment variables for Maven in your Windows system. After that, restart your command line. It will work.
answered Dec 16, 2020 by MD
• 95,460 points

Related Questions In DevOps Tools

0 votes
1 answer

error sudo: ./gradlew: command not found

Maybe..your Gradle path is not set for ...READ MORE

answered Sep 28, 2020 in DevOps Tools by Adil Abdullah Khan
4,714 views
0 votes
1 answer

Getting an Error while trying to push changes to cloud foundry

Here is an approach which you can ...READ MORE

answered Jul 19, 2018 in DevOps Tools by Atul
• 10,240 points
2,086 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,039 views
+2 votes
1 answer
0 votes
1 answer

Is terraform alternative to configuration management tools like ansible or puppet??

Ansible/Puppet/Chef is primarily a configuration management tool, ...READ MORE

answered Feb 3, 2020 in DevOps Tools by anonymous
• 59,230 points
1,415 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP