To install and configure Maven on MacOS, you can follow these steps:
- Open the terminal on your Mac.
- Install the Homebrew package manager by running the following command in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Maven by running the following command in the terminal:
brew install maven
- Verify that Maven has been installed by running the following command in the terminal:
mvn -version
- Set the environment variables for Maven by adding the following lines to the
.bash_profile
file in your home directory:
export M2_HOME=/usr/local/Cellar/maven/{VERSION}/libexec
export PATH=$PATH:$M2_HOME/bin
Replace {VERSION}
with the actual
version of Maven that you installed.
- Reload the
.bash_profile
file by running the following command in the terminal:
source ~/.bash_profile
- Verify that Maven has been configured correctly by running the following command in the terminal:
echo $M2_HOME
You should see the path to your Maven installation printed on the console.
Congratulations, you have successfully installed and configured Maven on your MacOS system!