How to install maven on Ubuntu 18.04 LTS (Linux)




Install-Maven-on-Ubuntu-16.04

In this tutorial we will see how to install Apache Maven on Ubuntu 18.04 linux.

Step 1. 

Please Make sure that JAVA_HOME environment variable is set and points to your JDK installation in your system.

So to install Java 8 Open the terminal and run the following command

$ sudo add-apt-repository ppa:webupd8team/java -y
$ sudo apt-get update
$ sudo apt install oracle-java8-installer
$ sudo apt install oracle-java8-set-default

Step 2.  Now we will install maven 

Install Maven-3

$ cd /opt/
$ sudo wget http://www-eu.apache.org/dist/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz
$ sudo tar -xf apache-maven-3.5.3-bin.tar.gz
$ sudo mv apache-maven-3.5.3/ apache-maven/
$ sudo update-alternatives --install /usr/bin/mvn maven /opt/apache-maven/bin/mvn 1001

Step 3 . verify if maven is installed

To verify maven  run the following command

$ mvn -v

or

$ mvn --version;

Output

Apache Maven 3.5.3 (...)
Maven home: ...
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: ...
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

Now Apache Maven is installed successfully on your Ubuntu 18.04.

Configuring Apache Maven Environment

cd in to the ‘/etc/profile.d’ folder and create a new file maven.sh.

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

Copy and paste the following configuration in maven.sh file

# 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=/opt/apache-maven
export MAVEN_HOME=/opt/apache-maven
export PATH=${M2_HOME}/bin:${PATH}

Save the file and close it.

provide the following commands to make maven.sh executable and reload it.

sudo chmod +x maven.sh
source maven.sh

SUCCESS !!!!


Video Instructions


 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Leave a Reply

Your email address will not be published.


*