QABash Community Forum

Please or Register to create posts and topics.

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

If you’re seeing the message 'mvn' is not recognized as an internal or external command, it means that Maven is not installed on your system or its path is not set correctly. Here’s how to fix that:

Step 1: Install Maven

  1. Download Maven:
  2. Extract Maven:
    • Extract the downloaded zip file to a location on your system (e.g., C:\Program Files\Apache\maven-x.x.x on Windows or /opt/maven on Linux/Mac).

Step 2: Set Up Environment Variables

For Windows

  1. Set MAVEN_HOME:
    • Right-click on This PC or Computer on your desktop or in File Explorer and select Properties.
    • Click on Advanced system settings.
    • Click on Environment Variables.
    • Under System Variables, click New.
      • Variable name: MAVEN_HOME
      • Variable value: Path to your Maven folder (e.g., C:\Program Files\Apache\maven-x.x.x).
  2. Update PATH Variable:
    • In the same Environment Variables window, find the Path variable in the System Variables section and select it.
    • Click Edit and add a new entry for Maven’s bin directory (e.g., C:\Program Files\Apache\maven-x.x.x\bin).
  3. Apply Changes:
    • Click OK to close all dialog boxes.

 

For macOS/Linux

  1. Open Terminal.
  2. Edit your profile (e.g., .bash_profile.bashrc, or .zshrc):
nano ~/.bash_profile  # or ~/.bashrc or ~/.zshrc depending on your shell
  1. Add the following lines:
export MAVEN_HOME=/path/to/apache-maven-x.x.x
export PATH=$MAVEN_HOME/bin:$PATH

Replace /path/to/apache-maven-x.x.x with the actual path where you extracted Maven.

  1. Save and Exit: (Press CTRL + X, then Y, and Enter in nano).
  2. Apply the changes:
source ~/.bash_profile  # or source ~/.bashrc or source ~/.zshrc

Step 3: Verify the Installation

  1. Open a new command prompt or terminal.
  2. Run the following command:
mvn -v

If Maven is installed correctly, you should see the version information displayed.

Once Maven is set up, you’ll be able to use the mvn command to run your tests and manage your project. If you have any further questions or issues, feel free to ask!

Scroll to Top
×