Set Maven Environment Variables on Mac

To set up Maven environment variables on Mac, you can follow these steps:

  1. Open the terminal.
  2. Edit the bash configuration file using the following command:
sudo nano ~/.bash_profile
  1. After entering the administrator password, a text editor will be opened. Add the following content to the end of the file:
export M2_HOME=/path/to/maven
export PATH=$PATH:$M2_HOME/bin

“path/to/maven” is the path where you have installed Maven.

  1. Press Control + X, then press Y to save the changes, and finally press Enter to exit the editor.
  2. Enter the following command to apply the configuration:
source ~/.bash_profile
  1. Enter the following command to verify if Maven is properly configured:
mvn -version

If the configuration is successful, you will see the version information of Maven.

Now you have successfully set up the Maven environment variables. You can now use Maven commands in the terminal to build and manage projects.

bannerAds