Java

MVN is Not Recognized as an Internal or External Command Operable Program or Batch File

“Apache Maven, or Maven for short, is a powerful open-source tool the Apache Group provides to develop, build, and deploy Java Applications using Project Object Model.
Although Maven is written in Java and commonly used to manage Java Applications, it can also be used to manage applications written in other languages such as C#, Ruby, Scala, etc.
As mentioned, Maven used Project Object Model to manage the specific projects. POM is simply an XML file that contains all the configuration and dependency details required for that application. This includes the project description, versioning, configuration entries, and many more. The POM XML file is located in the project’s root directory and is used by Maven to provision the project.
Before using Maven in your project, you must set up and have the tool running on your system.
Therefore, in this tutorial, we will show you how to install Apache Maven on your Windows Machine.”

Installing Maven on Windows

You can follow the steps in this article to download and install Maven on your machine.

Download the Maven Archive

The first step is to download and extract the Maven archive. You can do so by visiting the resource provided below.

https://maven.apache.org/download.cgi

On the Download page, locate the archive for your system and click to download.

Once downloaded, open your file explorer and navigate to the downloads location. Next, click on the downloaded archive.

This will prompt you to add the path where you would like to extract the Maven archive. Feel free to choose any location in which you have sufficient permissions.

Once extracted, you should find files and directories in the C:\apache-maven-3.8.6 as shown:

Add Maven to System Path

Once we have Maven extracted to the target directory, we must add it to the environment variables to access it from any location in our system.
To do this, open the start menu and search “env.”

Click on the “Edit the System Environment variables” from the search result.

Next, select “Environment Variables” in the “Advanced” tab of the System Properties Window.

Under “System Variables,” click on New to Add a new system environment variable.

Set the Variable name to MAVEN_HOME and the Variable Value as the path to the Maven directory (extracted previously).

You can also select Browse Directory to navigate through the file system. Click Ok to save.

To add the maven binary to the path, click on Path and Select “Edit, under the “System Variables.”

Click on “New” and add the path to the Maven binary. In our example, we set the maven path to %MAVEN_HOME%\bin

By adding the Maven binary to the path, you will resolve the “mvn command ‘mvn’ is not recognized as an internal or external command, operable program, or batch file error.

To verify that Maven is installed successfully on your system, run the command:

mvn -version

The command above should return detailed information about the installed Maven version.

NOTE: Ensure you have a Java JDK or equivalent environment installed on your system.

Conclusion

Through this guide, you have downloaded and configured the Apache Maven tool on your Windows system.

Thanks for reading & See you in the next one!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list