Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Maven build: mvn.bat not recognized

While trying to build a Java project under NetBeans (with an external Maven configured), I got the following error:

"C:\Users......\bin\mvn.bat"" is not recognized as an internal or external command, operable program or batch file"

Edit: Using Maven 3.3.3, Windows 10; Added custom maven to NetBeans under Tools > Options > Java > Maven > Execution > Maven Home > Browse

What can I do?

like image 237
Luís Soares Avatar asked Sep 21 '15 23:09

Luís Soares


People also ask

Where can I find Mvn bat?

bat file at the 'C:\apache-maven-3.3. 9\bin' location.

Why Maven is not showing in command prompt?

If they don't exist then you need to right click My Computer--> Properties --> Advanced --> Environment variables. Add M2_HOME and JAVA_HOME environment variables there. To add M2_HOME do the same, set it to your location, for example: "C:\Program Files\Apache Software Foundation\apache-maven-3.3. 3".


2 Answers

To solve it:

  1. Go to the Maven installation folder
  2. Go to bin
  3. Make sure you can see file extensions
  4. Duplicate mvn.cmd and mvnDebug.cmd and rename those copies to have the extension .bat
  5. Try building the project now

source

like image 123
Luís Soares Avatar answered Oct 07 '22 00:10

Luís Soares


Install Netbeans 8.1 or later to correct this issue.

As @mkleint noted, this is a problem with Maven 3.3.3+ where maven changed the mvn executable extension.You can download the latest version on the Netbeans website.

like image 35
Chic Avatar answered Oct 06 '22 23:10

Chic