• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Apache Maven on Debian 10

Written by Admin, Updated On July 11, 2020
java, maven, ubuntu
How to Install Apache Maven on Debian 10

Apache Maven is a very useful open-source project management tool based on POM (project object model). Primarily, it is used to manage Java projects and manage a project’s build, reporting, and documentation. This tutorial show you how to install and configure Apache Maven on Debian 10.

Prerequisites#

Before starting installation, ensure that you are logged in as root or user with sudo privileges.

Installing Apache Maven on Debian 10 with apt#

The official Debian repositories includes Maven packages and it can be installed with the apt package manager.

It is very a simple and straightforward process to install Maven on Debian.

At first, update the package index:

sudo apt update

Run the below command install Maven:

sudo apt install maven

Verify the installation by typing:

mvn -version

It will show you something like this:

Maven home: /usr/share/maven
Java version: 11.0.6, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-6-amd64", arch: "amd64", family: "unix"

It’s done. Maven is installed on your system, and ready to start using it.

Installing the Latest Release of Apache Maven#

Perform the following steps to download and install the latest version of Apache Maven on Debian 10.

1. Install OpenJDK#

JDK 1.7 or above need to be installed for Maven 3.3+ version. To install OpenJDK 11, type:

sudo apt update
sudo apt install default-jdk

Verify the installation by running the following command:

java -version

It should show output like below:

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)

2. Downloading Apache Maven#

Visit the Maven download page to see the latest version of Maven. Currently, at the time of writing this article, the latest version of Apache Maven is 3.6.3.

We will download the Apache Maven in the /tmp directory:

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

After complete the download, extract the archive in the /opt directory:

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

To control the Maven versions and updates, create a symbolic link for maven that will point to the Maven installation directory:

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

To upgrade your Maven installation, unpack the newer version and change the symlink and point to it.

3. Setup environment variables#

Now we will set up environment variables, to do so open your text editor and create a new file named mavenenv.sh in the /etc/profile.d/ directory.

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

Put the following following code lines in to it:

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 and close the file.

We should make this script executable using chmod command:

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

At last, load the environment variables using the source command:

source /etc/profile.d/maven.sh

4. Verify the installation#

To verify the installation, use the mvn -version command to check the Maven version:

mvn -version

It should print like the following:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven
Java version: 11.0.6, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.19.0-6-amd64", arch: "amd64", family: "unix"

It’s done. The latest version of Maven is now installed on your Debian system.

Conclusion#

You have learned how to install Apache Maven on Debian 10. To learn more about Apache Maven visit the official Apache Maven Documentation page.

If you have any question or feedback, don’t hesitate to leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install CouchDB on Debian 10 Buster
Next Article   How to Install Vagrant on Debian 10

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Memcached on Ubuntu 22.04

    How to Install Memcached on Ubuntu 22.04

    March 16, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook