How to Install Apache Maven on Debian 9

Introduction

Apache Maven is a popular open source build automation tool used for Java projects. It is used to manage the project’s build, dependency, and documentation. Installing Apache Maven on Debian 9 is a straightforward process that can be completed in a few simple steps. This guide will walk you through the process of installing Apache Maven on Debian 9.

How to Install Apache Maven on Debian 9

1. First, update the package index:

sudo apt update

2. Install the Maven package:

sudo apt install maven

3. Verify the installation by checking the version:

mvn -v

4. You should see the following output:

Apache Maven 3.5.4 (…)
Maven home: /usr/share/maven
Java version: 1.8.0_212, 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”
[ad_1]

Introduction

Apache Maven is a project management tool for developing Java applications.

It resembles other Linux-based project management tools but differs in that it is designed to provide a comprehensive and easy-to-read status of a project. It also incorporates a POM (Project Object Model) approach, meaning that it uses standardized software libraries and plugins.

This guide will walk you through how to install Apache Maven on Debian 9.

how to install apache maven on debian9

Prerequisites

  • A system running Debian 9
  • Access to a user account with sudo or root privileges
  • Access to a terminal window/command line (Ctrl-Alt-F2)
  • The apt package manager, included by default
  • (optional) The wget command

Option 1: Install Apache Maven on Debian with Yum

1. As with most software installations, start by updating the repository index:

sudo apt update

Allow the operation to complete.

2. Install Apache Maven by entering the following:

sudo apt install maven

Allow the installation to complete.

3. Verify the installation by checking the Maven version:

mvn –version

Option 2: Install Latest Version of Apache Maven

Step 1: Install Java Development Kit

Apache Maven requires the Java Development Kit (JDK). This tutorial uses the open-source OpenJDK software package. For compatibility, make sure you are using version 1.7 or higher.

1. In a terminal window, enter the following:

sudo apt install default-jdk

2. Confirm the Java installation and version by entering:

java –version

The first line should return openjdk version “1.8.0_181” or higher.

Step 2: Download Apache Maven for Debian

Note: At the time this article was written, Apache Maven was at version 3.6.0. If you need a more recent version, please see the developer’s download page.

1. Use the wget command to download the files to the /tmp directory:

sudo wget http://ftp.naz.com/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz –P /tmp

If you get an error “command not found,” use the following to install wget:

sudo apt install wget

Once the wget installation finishes, you should be able to download the file.

2. Next, extract the .tar.gz file to the /opt directory:

sudo tar xf /tmp/apache-maven-3.6.0-bin.tar.gz –C /opt

Note: If you’re using a different version of Maven, change 3.6.0 to the version you downloaded.

Finally, create a symbolic link to the software location. This helps make typing the location easier for updates and other tasks:

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

Step 3: Configure Enviroment

Like most Linux software, Apache Maven uses a configuration file. This file is located at /etc/profile.d/maven.sh.

1. Create the file and open it for editing:

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

2. Enter the following lines:

# Apache Maven Environmental Variables

# MAVEN_HOME for Maven 1 - M2_HOME for Maven 2

export JAVA_HOME=/usr/lib/jvm/default-java

export M2_HOME=/opt/maven

export MAVEN_HOME=/opt/maven

export PATH=${M2_HOME}/bin:${PATH}

Save the file and exit.

3. Next, change permissions by entering the following:

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

4. Then load the file by entering:

Source /etc/profile.d/maven.sh

Step 4: Verify Apache Maven Installation

Enter the following:

mvn –version

The system should display your Apache Maven version, the location of Maven Home, and your Java version.

Conclusion

You should now have successfully installed Apache Maven on your Debian 9 server.

For more tutorials, read our article and find out how to install Maven on Ubuntu.

For more information, please see the offical maven documentation.

[ad_2]

How to Install Apache Maven on Debian 9

Apache Maven is a popular open source build automation tool used for Java projects. It is used to manage dependencies, build, test, and deploy projects. In this tutorial, we will show you how to install Apache Maven on Debian 9.

Prerequisites

  • A server running Debian 9.
  • A root user or user with sudo privileges.

Step 1: Update the System

Before starting, it is recommended to update the system packages to the latest version. You can do this by running the following command:

sudo apt-get update
sudo apt-get upgrade

Step 2: Install Java

Apache Maven requires Java to be installed on the system. You can install the default OpenJDK package by running the following command:

sudo apt-get install default-jdk

Once the installation is completed, you can verify the Java version by running the following command:

java -version

Step 3: Download Apache Maven

You can download the latest version of Apache Maven from the official website. At the time of writing this article, the latest version is 3.6.3.

wget http://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

Step 4: Install Apache Maven

Once the download is completed, extract the downloaded archive file to the /opt directory:

sudo tar xf apache-maven-3.6.3-bin.tar.gz -C /opt

Next, create a symbolic link of the maven folder to the /usr/local/ directory:

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

Step 5: Setup Environment Variables

Next, you will need to setup environment variables for Apache Maven. You can do this by creating a maven.sh file in the /etc/profile.d/ directory:

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

Add the following lines:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
export M2_HOME=/usr/local/apache-maven
export MAVEN_HOME=/usr/local/apache-maven
export PATH=${M2_HOME}/bin:${PATH}

Save and close the file, then reload the system variables by running the following command:

source /etc/profile.d/maven.sh

Step 6: Verify the Installation

At this point, Apache Maven is installed on your Debian 9 system. You can verify the installation by running the following command:

mvn -v

You should see the following output:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-6-amd64", arch: "amd64", family: "unix"

Congratulations! You have successfully installed Apache Maven on your Debian 9 server.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00