Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Apache Maven on Debian 10 - DesignLinux

Jul 11 2020
designlinux 0 Comments
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.

Related

Tags: java, maven, ubuntu

How To Set Up Nginx Server Blocks on Ubuntu 20.04

Prev Post

How to Install Gradle on Ubuntu 20.04

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 1,253
  • 609,701

DesignLinux.com © All rights reserved

Go to mobile version