How to install Maven on Mac if you can’t save it on your computer

By: Slav Kurochkin

Recently I was trying to install Maven on Mac OS like the code bellow

$ export M2_HOME=/Users/your_directory/apache-maven-3.1.1/bin:{PATH}
$ export M2_PATH=/Users/your_directory/apache-maven

But I was facing to a problem each time when you closing Terminal Maven was not saving on Mac, so you have to do same thing over and over again. So there is one solution which I would like to share:

// navigate to directory in Terminal
 cd ~
// then type in Terminal code bellow to open TextEdit with .bash_profile file
open -a TextEdit .bash_profile

// once you open file copy and past code bellow in your Text Editor under existing text in it

export JAVA_HOME=$(/usr/libexec/java_home)
export M2_HOME="/Users/your_directory/apache-maven-3.1.1"
export M2="$M2_HOME/bin"
export PATH="$JAVA_HOME/bin:$PATH"
export PATH="$M2:$PATH"

// then type in terminal
source .bash_profile
View Comments

Leave a Comment

Use markdown or basic HTML and be nice.