• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Apache Maven on Debian 10/9/8

Written by Rahul, Updated on April 12, 2020

Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on Debian 10, Debian 9 and Debian 8 systems.

You may like:

  • How to Install Gradle on Debian 10

Step 1 – Prerequisites

Login to your Debian system using shell access. For the remote systems connect over SSH connection.

ssh [email protected]

Run below commands to upgrade the current packages to the latest version.

sudo apt update 
sudo apt upgrade

Step 2 – Java Installation

Apache Maven required Java to be installed on your system. I have installed latest Java 11 on my Debian system using this tutorial.

java -version 

java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

Step 3 – Install Maven on Debian

After installation of Java. You are read to install Apache Maven on Debian. Download the Apache maven archive file from its official website or use following command to download Apache Maven 3.6.3.

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

Extract downloaded archive using following command.

sudo tar xzf apache-maven-3.6.3-bin.tar.gz
sudo ln -s apache-maven-3.6.3 apache-maven

Step 4 – Configure Maven Environment

You need to set the M2_HOME and MAVEN_HOME environment variables to work with Maven on Debian. Also, set the bin directory to the PATH environment variable. You can set the environments variables by creating new file /etc/profile.d/apache-maven.sh.

sudo vi /etc/profile.d/apache-maven.sh

and add following content.

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

Now load the environment variables in current shell using following command.

source /etc/profile.d/apache-maven.sh

Step 5 – Verify Installation

You have successfully installed and configured Apache Maven on your Ubuntu system. Use the following command to check the version of Maven.

mvn -version

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/apache-maven
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-oracle
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-46-generic", arch: "amd64", family: "unix"

The Installation of Apache Maven on Debian system has been completed successfully. You can now remove the downloaded archive file from your system to free space.

rm -f apache-maven-3.6.0-bin.tar.gz

To read more about Apache Maven visit here.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

2 Comments

  1. Avatar Ray Reply
    June 18, 2019 at 8:43 am

    Thank you

  2. Avatar Vitor Reply
    April 5, 2019 at 4:43 pm

    Thank you! It worked here.

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy