banner



How To Install Maven On Linux

Ubuntu and most other Linux distributions have Apache Maven in their official repository but I adopt manual installation to avoid dependencies like Open JDK. This commodity explains how y'all can install the latest Apache Maven in Linux.

Requirements:

Apache Maven depends on Java Development Kit and then you must have either Oracle JDK or OpenJDK installed on your system. In case if you practice non have JDK in your system, follow these articles first and install Oracle JDK on your estimator.

  • Install Oracle JDK 8 on Linux
  • Install Oracle JDK 11 on Linux


Step one:
Download apache-maven-$maven_version-bin.tar.gz binary archive from the official link. This article uses the Maven version $maven_version. Yous need to replace the version number past whatever the version you are downloading.

Step 2:
Open the Last and alter the directory to /opt folder.

          cd /opt        

Step 3:
Extract the apache-maven archive into the opt directory.

          sudo tar -xvzf ~/Downloads/apache-maven-$maven_version-bin.tar.gz        

Step 4:
Edit the /etc/environs file and add together the following surround variable:

          M2_HOME="/opt/apache-maven-$maven_version"        

also, append the bin directory to the PATH variable:

          /opt/apache-maven-$maven_version/bin        

You can use nano to edit the file in the terminal itself. Execute the following command and alter the content equally given below.

          sudo nano /etc/environment        

Alert: Do not replace your environment file with the following content because y'all may already accept different environment variables which are required by other applications to role properly. Notice the terminate of PATH variable and the M2_HOME variable.

          PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk-10.0.2/bin:/opt/apache-maven-$maven_version/bin" JAVA_HOME="/usr/lib/jvm/jdk-10.0.2" M2_HOME="/opt/apache-maven-$maven_version"        

After the modification, printing Ctrl + O to salvage the changes and Ctrl + Ten to exit nano.

Step 5:
Update the mvn command:

          sudo update-alternatives --install "/usr/bin/mvn" "mvn" "/opt/apache-maven-$maven_version/bin/mvn" 0 sudo update-alternatives --set mvn /opt/apache-maven-$maven_version/bin/mvn        

Stride half dozen:
Add Fustigate completion to mvn so that you can complete complex Maven commands by hitting Tab multiple times.

          sudo wget https://raw.github.com/dimaj/maven-bash-completion/primary/bash_completion.bash --output-document /etc/bash_completion.d/mvn        

Credits to Juven Xu: maven-bash-completion

Pace seven:
Logout and login to the figurer and check the Maven version using the following control.

          mvn --version        

If information technology works, hooray! you have successfully installed the latest Apache Maven on your computer.

Source: https://www.javahelps.com/2017/10/install-apache-maven-on-linux.html

Posted by: coniglioonced1974.blogspot.com

0 Response to "How To Install Maven On Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel