How Do You Install Maven on Linux?

Problem scenario
How do you install Apache Maven on any distribution of Linux?

Prerequisite: You must have Java installed for Maven to work after it is installed. It may make sense to install Java before you install Maven. Understand that mvn commands will not work until Java has been installed. If you need assistance install Java, see this posting.

This is based on Apache Maven 3.6.3.*

curl$mavenversion/binaries/apache-maven-$mavenversion-bin.tar.gz > /tmp/apache-maven-$mavenversion-bin.tar.gz
cd /tmp/
sudo tar -xzvf apache-maven-$mavenversion-bin.tar.gz
sudo mv apache-maven-$mavenversion /opt/maven
export M2_HOME=/opt/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
source ~/.bashrc
ln -s /opt/maven/bin/mvn /bin/mvn
mvn -v

*You can change the directions if you want. You can get the latest installation media from here:

Leave a comment

Your email address will not be published. Required fields are marked *