If you get a "zsh: command not found: mvn" error, it means that the
mvn command is not available in your
PATH environment variable. This can happen if Apache Maven is not installed on your system, or if it is installed but the
mvn command is not added to your
How to fix zsh: command not found: mvn
To fix this error, you can try the following steps:
Check if Apache Maven is installed on your system by running the
mvn -vcommand. This should print the version of Maven installed on your system, if it is installed.
If Maven is not installed, you can install it by following the instructions on the Apache Maven website.
If Maven is installed, but the
mvncommand is not available in your
PATHvariable, you can add it to your
PATHvariable by following these steps:
~/.zshrcfile in a text editor.
Add the following line to the file, replacing
<maven-install-dir>with the directory where Maven is installed:
~/.zshrcfile and run the
source ~/.zshrccommand to reload the file and update your
After following these steps, you should be able to run the
mvn command without getting the "zsh: command not found: mvn" error.
Install Maven on Your System
To install Maven on your system, you'll need to follow these steps:
Visit the Maven website and download the latest version of Maven.
Unzip the downloaded file and move it to a directory of your choice. In this example, we'll move it to the /usr/local/ directory.
sudo tar -xf apache-maven-3.8.3-bin.tar.gz -C /usr/local/
Rename the extracted directory to a simpler name like "apache-maven."
sudo mv /usr/local/apache-maven-3.8.3 /usr/local/apache-maven
Set the MAVEN_HOME environment variable by adding the following line to your ~/.zshrc file:
Update your system's PATH variable by adding the following line to your ~/.zshrc file:
Reload your ~/.zshrc file by running the following command:
Test if Maven is installed correctly by running the following command:
If Maven is installed correctly, you should see an output that displays the version of Maven installed on your system.