YouTube Icon

Code Playground.

How to Install Apache Maven on Ubuntu 20.04

CFG

How to Install Apache Maven on Ubuntu 20.04

Apache Maven is an open-source venture the board and perception apparatus utilized essentially for Java ventures. Expert uses a Project Object Model (POM), which is basically a XML record containing data about the venture, design subtleties, the task's conditions, and the sky is the limit from there. 

In this instructional exercise, we will give both of you various approaches to introduce Apache Maven on Ubuntu 20.04. 

The authority Ubuntu vaults contain Maven bundles that can be introduced with the able bundle director. This is the most straightforward approach to introduce Maven on Ubuntu. In any case, the rendition remembered for the vaults may fall behind the most recent adaptation of Maven. 

To introduce the most recent variant of Maven, adhere to the directions gave in the second aspect of this article that tells the best way to download the paired circulation chronicle from their official site. 

Pick the establishment strategy that is generally fitting for your arrangement and climate. 

Prerequisites

The directions expect that you are signed in as root or client with sudo benefits . 

Introducing Apache Maven on Ubuntu 20.04 with adept 

Introducing Maven on Ubuntu utilizing adept is a basic, clear cycle. 

Update the bundle list and introduce Maven by entering the accompanying orders: 

sudo apt update
sudo apt install maven

To confirm the establishment, run mvn - rendition: 

mvn -version

The yield should look something like this: 

Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-26-generic", arch: "amd64", family: "unix"

That is it. Expert is currently introduced on your framework, and you can begin utilizing it. 

Installing the Latest Release of Apache Maven

In this segment, we'll give a bit by bit guidelines about how to download and introduce the most recent Apache Maven form on Ubuntu 20.04. 

1. Install OpenJDK

Expert 3.3+ requires JDK 1.7 or above to be introduced. 

Introduce OpenJDK 11 , by composing: 

sudo apt update
sudo apt install default-jdk

Check the establishment by running the accompanying order: 

java -version

The yield should look something like this: 

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

2. Downloading Apache Maven

At the hour of composing this article, the most recent adaptation of Apache Maven is 3.6.3. Prior to proceeding with the subsequent stage, visit the Maven download page to check whether a more current variant is accessible. 

Download the Apache Maven in the/tmp catalog: 

wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp

Once the download is finished, extricate the file in the/select index: 

sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt

To have more power over Maven forms and updates, we will make a representative connection expert that will highlight the Maven establishment registry: 

sudo ln -s /opt/apache-maven-3.6.3 /opt/maven

At the point when another variant is delivered, you can update your Maven establishment, by unloading the more up to date form and change the symlink to highlight it. 

3. Setup environment variables

Next, we'll have to set up the climate factors. To do as such, open your word processor and make another record named mavenenv.sh in the/and so on/profile.d/index. 

/etc/profile.d/maven.sh

export JAVA_HOME=/usr/lib/jvm/default-java
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Spare and close the document. This content will be sourced at shell startup. 

Make the content executable with chmod : 

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

4. Check the establishment 

To check that Maven is introduced, utilize the mvn - variant order which will print the Maven form: 

mvn -version

You should see something like the accompanying: 

Maven home: /opt/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-26-generic", arch: "amd64", family: "unix"

That is it. The most recent rendition of Maven is currently introduced on your Ubuntu framework. 

Conclusion

We have told you the best way to introduce Apache Maven on Ubuntu 20.04. You should now visit the official Apache Maven Documentation page and figure out how to begin with Maven. 

In the event that you hit an issue or have criticism, leave a remark underneath.




CFG