Ubuntu

Tutorial To Install Apache Maven On Ubuntu And Debian

Tutorial To Install Apache Maven On Ubuntu And Debian

In this tutorial post, we will show you the method to install Apache Maven on Ubuntu and Debian. Before proceeding for the installation of Apache Maven, you have to install JDK in your system. You can follow our tutorial on how to install OpenJDK 8 in Ubuntu & Debian

Tutorial To Install Apache Maven On Ubuntu And Debian

Tutorial To Install Apache Maven On Ubuntu And Debian

Open your terminal and execute the following commands to install Apache Maven.

$ sudo cd /usr/local/src
$ sudo wget http://www-us.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

Now, Extract the downloaded archive apache-maven-3.5.4-bin.tar.gz file and rename the directory to apache-maven using following commands.

$ sudo tar -xf apache-maven-3.5.4-bin.tar.gz
$ sudo mv apache-maven-3.5.4/ apache-maven/ 

Configure the environments variables for Apache Maven files by creating a new configuration file ‘maven.sh’ in the ‘/etc/profile.d’ directory in your system.

$ sudo cd /etc/profile.d/
$ sudo nano maven.sh

Add the following environment variables in maven.sh.

# Apache Maven Environment Variables
# MAVEN_HOME for Maven 1 - M2_HOME for Maven 2
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export M2_HOME=/usr/local/src/apache-maven
export MAVEN_HOME=/usr/local/src/apache-maven
export PATH=${M2_HOME}/bin:${PATH}

Now it’s time make the ‘maven.sh’ configuration file executable and then you have to load the configuration with the help of the ‘source’ command.

$ sudo chmod +x maven.sh
$ sudo source /etc/profile.d/maven.sh

After all process, check the version of Apache maven installed in your system:

$ mvn --version

 

Enjoy  !!



READ THIS ALSO  Install Android Studio on Ubuntu 18.04 LTS