If you encounter the error message "mvn is not recognized as an internal or external command" in Windows, it means that the Maven command-line tool is not properly installed or configured in your system. Here are steps to solve this issue:
Check Maven Installation: First, make sure that Maven is installed on your system. You can download the Maven binary distribution from the official Apache Maven website (https://maven.apache.org/download.cgi) and follow the installation instructions.
Set Maven Path: After installing Maven, you need to set the M2_HOME and MAVEN_HOME environment variables to point to the Maven installation directory, and add the Maven bin directory to the system PATH. Here's how you can do it:
Right-click on "This PC" (or "My Computer") and select "Properties."
Click on "Advanced system settings" on the left.
In the System Properties window, click on the "Environment Variables" button.
In the Environment Variables window, under "System Variables," click "New" and add a variable named M2_HOME (or MAVEN_HOME) with the Maven installation directory as its value (e.g., C:pache-maven-3.8.4).
Find the "Path" variable in the list of system variables, select it, and click "Edit."
Add %M2_HOME%in to the list of paths (make sure to separate it with a semicolon from existing paths).
Click "OK" to save the changes and close the Environment Variables window.
Restart Command Prompt: After setting the environment variables, close and reopen the command prompt window (or restart your computer) to apply the changes.
Verify Installation: To verify that Maven is correctly installed and configured, open a new command prompt window and run the following command:
mvn -version
If Maven is properly installed and configured, you should see the Maven version and other information printed in the console.
By following these steps and ensuring that Maven is correctly installed and configured, you should be able to resolve the "mvn is not recognized as an internal or external command" error in Windows.