Note: When originally posted I was trying to install maven2. Since the main answer is for maven3 I have updated the title. The rest of the question remains as it was origina
Pretty much what others said, but using "~/.bash_profile" and step by step (for beginners):
cd ~ && mkdir installed-packagessudo yum install -y wgetcd ~/installed-packageswget http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gztar -xvf apache-maven-3.5.0-bin.tar.gzln -s ~/installed-packages/apache-maven-3.5.0 /usr/local/apache-maven~/.bash_profile (This is where environment variables are commonly stored):
vi ~/.bash_profileMVN_HOME=/usr/local/apache-maven (do this before PATH variable is defined)
vi tool: Press i key to enable insert mode):$MVN_HOME:$MVN_HOME/binvi tool: Press esc key to exit insert mode and :wq! to save and quit file)source ~/.bash_profilemvn --help