YouTube Icon

Code Playground.

How to Install Apache Maven on Debian 9

CFG

How to Install Apache Maven on Debian 9

Apache Maven is an open-source venture the executives and perception device utilized principally for Java ventures. Expert uses a Project Object Model (POM),which is basically a XML record containing data about the undertaking, setup subtleties, the task's conditions, etc. 

In this instructional exercise, we will show both of you various approaches to introduce Apache Maven on Debian 9. 

The authority Debian archives contain Maven bundles that can be introduced with the well-suited bundle director. This is the most effortless approach to introduce Maven on Debian. Notwithstanding, the variant remembered for the vaults is consistently a few deliveries behind the most recent form of Maven. 

Also Read:-How to Install and Use PHP Composer on Debian 10

To introduce the most recent adaptation of Maven, adhere to the directions gave in the second piece of this article. 

Pick one of the establishment strategies that turns out best for you. 

Prerequisites

To have the option to introduce bundles on your Debian framework, you should be signed in as a client with sudo advantages . 

Installing Apache Maven on Debian with Apt

Introducing Maven on Debian utilizing well-suited is a basic, clear cycle. 

To start with, update the bundle record: 

sudo apt update

Introduce Maven by running the accompanying order: 

sudo apt install maven
Also Read:-How to Install Memcached on Debian 10

Check the establishment by composing: 

mvn -version

The yield should look something like this: 

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.0-8-amd64", arch: "amd64", family: "unix"

 That is it. Expert is presently introduced on your Debian framework. 

Install the Latest Release of Apache Maven

The accompanying segments give definite data to introducing the most recent Apache Maven form on Debian 9. We will download the most recent arrival of Apache Maven from the official merchant site. 

Also Read:-How to Install Tor Browser on Ubuntu 20.04

1. Install OpenJDK

Expert 3.3+ requires JDK 1.7 or above to be introduced on your framework. We'll introduce OpenJDK , which is the default Java improvement and runtime in Debian 9. 

Start by refreshing the bundle file: 

sudo apt update

Introduce the OpenJDK bundle by composing: 

sudo apt install default-jdk

Confirm the Java establishment by checking its variant: 

java -version

The yield should look something like this: 

openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

op

2. Download Apache Maven

At the hour of composing this article, the most recent form of Apache Maven is 3.6.0. Prior to proceeding with the following stage, you should check the Maven download page to check whether a more up to date form is accessible. 

Also Read:-How to Install Gitea on CentOS 8

Download the Apache Maven chronicle in the/tmp catalog utilizing the accompanying wget order: 

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

Once the download is finished, separate the file in the/pick registry: 

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

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

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

Afterward in the event that you need to redesign your Maven establishment, you can essentially unload the more current form and change the symlink to highlight the most recent rendition. 

Also Read:-How to Install Apache Cassandra on CentOS 8

3. Setup environment variables

Next, we'll need to set up the climate factors. To do as such, open your content tool and make another record named mavenenv.sh within the/and so on/profile.d/index. 

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

Glue the accompanying design: 

/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 record. This content will be sourced at shell startup. 

Make the content executable by composing the accompanying chmod order: 

sudo chmod +x /etc/profile.d/maven.sh
Also Read:-How to Set Up a Firewall with UFW on Debian 10

At last burden the climate factors utilizing the source order: 

source /etc/profile.d/maven.sh

4. Verify the installation

To approve that Maven is introduced appropriately utilize the mvn - form order which will print the Maven rendition: 

mvn -version

You should see something like the accompanying: 

Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z)
Maven home: /opt/maven
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.0-8-amd64", arch: "amd64", family: "unix"

That is it. The most recent adaptation of Maven is currently introduced on your Debian framework. 

Also Read:-How to Install Visual Studio Code on Debian 10

Conclusion

You have effectively introduced Apache Maven on your Debian 9. You would now be able to visit the official Apache Maven Documentation page and figure out how to begin with Maven. 

On the off chance that you hit an issue or have criticism, leave a remark underneath.




CFG