How to install Maven in Linux/Unix

  • Home
  • How to install Maven in Linux/Unix

First of all download the maven tar into the environment. Below I have show the command to download maven 3.5.0


Now Apache maven tar binary will be downloaded to where you execute above command. Then untar the binary file using below command

tar -xvf apache-maven-3.5.0-bin.tar.gz

Now we are going to set up maven for you. You can copy unzipped folder to where ever you want it to be. My case I will create a folder called usersettings and move the maven folder into usersettings folder.

Now need to set up path variables for M2_HOME and M2 variables like below

export M2_HOME=/home/ec2-user/usersettings/apache-maven-3.5.0
export M2=$M2_HOME/bin

And attach JVM memory for maven process like below
export MAVEN_OPTS=-Xmx1024m

Now you are ready to go and you can just type mvn -version or mvn to test maven successfully set up on your environment