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

    How to Install Apache Maven on Ubuntu 20.04

    By RahulDecember 9, 20222 Mins Read

    Apache Maven is a powerful tool for managing Java projects. It is used to build and manage projects written in Java and other languages. It has a wide range of features, including dependency management, project structure, and configuration. In this article, we will be discussing how to install Apache Maven on Ubuntu 20.04. This guide will take you through the step-by-step process of installing Apache Maven on Ubuntu 20.04. Let’s get started!

    Advertisement

    You may like:

    • How to Install Gradle on Ubuntu 20.04

    Prerequisites

    Apache Maven required Java language for running on any operating system. So first of all, Make sure you have Java installed on your system. also make sure you have installed JDK and JRE both.

    java -version 
    
    openjdk 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)
    

    If you don’t have Java Development Kit installed on your system. Use the below command to install it.

    sudo apt install default-jdk
    

    Step 1 – Installing Apache Maven on Ubuntu

    You can download Apache maven from its official website or use the following command to download Apache Maven 3.8.6 on your system.

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

    Now extract the downloaded archive using the following command.

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

    Step 2 – Setup Environment Variables

    As you have downloaded pre-compiled Apache Maven files on your system. Now set the environment variables by creating new file /etc/profile.d/maven.sh.

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

    Update the following content to file:

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

    Save your file and close.

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

    source /etc/profile.d/maven.sh
    

    Step 3 – Verify Installation

    You have successfully installed and configured Apache Maven on your Ubuntu system. To find the current installed Maven version, type:

    mvn -version
    
    Apache Maven 3.8.6 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
    Maven home: /usr/local/maven
    Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
    Default locale: en, platform encoding: UTF-8
    OS name: "linux", version: "5.4.0-26-generic", arch: "amd64", family: "unix"
    

    Finally, clean up the disk by removing the downloaded archive file.

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

    Conclusion

    In this tutorial, You have learned about the installation of Apache Maven on the Ubuntu system.

    Apache Maven Ubuntu 20.04
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Apt configuration file options /etc/apt/apt.conf

    Comparing Apache MPM Worker and Prefork: Which is Right for Your Application

    How to Install Apache (httpd) on RHEL & CentOS Stream 9

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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