Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»Debian»How to Install Maven on Debian

    How to Install Maven on Debian

    By RahulSeptember 8, 20222 Mins Read

    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 11, Debian 10, Debian 9, and Debian 8 systems.

    Advertisement

    You may like:

    • How to Install Gradle on Debian 10

    Prerequisites

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

    ssh [email protected]
    

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

    sudo apt update 
    sudo apt upgrade
    

    Step 1 – Install Java

    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 2 – Installing Maven on Debian

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

    cd /usr/local
    wget https://www-us.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
    

    Extract the downloaded archive using the following command.

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

    Step 3 – 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 the 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 the current shell using the following command.

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

    Step 4 – 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.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
    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 the 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.8.5-bin.tar.gz
    

    To read more about Apache Maven visit here.

    Apache Maven install maven install maven on linux Maven
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Using the Apt Package Manager on Debian-based Systems

    How to Setup DKIM (DomainKeys) with Postfix

    A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!

    Installing Maven on macOS

    How to Install Maven on macOS (2 Methods)

    View 2 Comments

    2 Comments

    1. Ray on June 18, 2019 8:43 am

      Thank you

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

      Thank you! It worked here.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Python Function with Parameters, Return and Data Types
    • free Command in Linux (Check Memory Uses)
    • Git Rebase: A Practical Guide
    • How to move the complete Git repository
    • Handling Special Characters in Shell Scripts
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.