This article will guide you on how to install Apache Maven on Ubuntu. Same instructions could be followed for other Linux distributions as well.
Get latest version of Maven binary from below official site.
https://maven.apache.org/
Download Maven.
cd ~/Downloads
wget http://apache.mesi.com.ar/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
Extract and copy maven to local directory.
tar -xvf apache-maven-3.5.2-bin.tar.gz
mv apache-maven-3.5.2 /usr/local/
Set Maven command in environment variable.
Update ~/.bashrc – create this file if doesn’t exist.
vi ~/.bashrc
Add below lines at the end.
export MAVEN_HOME=/usr/local/apache-maven-3.5.2
export PATH=$PATH:$MAVEN_HOME/bin
Reload environment variables.
source ~/.bashrc
Check if “mvn” command works now.
mvn -version
If everything is good, you should see output like below.
Apache Maven 3.5.2
Maven home: /usr/local/apache-maven-3.5.2
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /usr/local/java/jdk1.8.0_144/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "4.8.0-36-generic", arch: "amd64", family: "unix"
Maven is installed now.