Skip to main content

How to Install Apache Maven on Linux: Step-by-Step Guide

HardReset.InfoJanuary 17, 20265 min16 views
11 connections·17 entities in this video→

Prerequisites for Maven Installation

  • πŸ’‘ Before installing Maven, ensure Java is installed on your Linux system by running java -version.
  • 🎯 Maven is a build automation and project management tool for Java, requiring a Java Development Kit (JDK) to function.

Method 1: Package Manager Installation

  • πŸ“¦ For Ubuntu/Debian systems, use sudo apt install maven.
  • πŸ“¦ For Fedora or similar distributions, use sudo dnf install maven.
  • ⚠️ This method is quick but might install an older version of Maven.

Method 2: Official Binary Installation

  • 🌐 Navigate to the official Apache Maven website to download the latest binary distribution.
  • πŸ—œοΈ Download the bin.tar.gz archive for your Linux system.
  • πŸ“‚ Extract the downloaded archive using the tar -xvzf <archive_name>.tar.gz command in your Downloads folder.

Setting Up Environment Variables

  • πŸ“‚ Move the extracted Maven folder to a standard location like /opt using sudo mv apache-maven-<version> /opt/maven.
  • ✍️ Edit your ~/.bashrc file using a text editor (e.g., nano ~/.bashrc) to add environment variables.
  • πŸš€ Add the following lines to ~/.bashrc:
    • export M2_HOME=/opt/maven
    • export PATH=$M2_HOME/bin:$PATH
  • πŸ’Ύ Save the changes by pressing Ctrl+O, Enter, and exit with Ctrl+X.

Verification

  • πŸ”„ Apply the changes to your current terminal session by running source ~/.bashrc.
  • βœ… Verify the Maven installation by typing mvn -version in the terminal.
  • 🎯 A successful output will display the installed Maven version and the Maven home directory.
Knowledge graph17 entities Β· 11 connections

How they connect

An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.

Hover Β· drag to explore
17 entities
Chapters3 moments

Key Moments

Transcript22 segments

Full Transcript

Topics14 themes

What’s Discussed

Apache MavenLinux InstallationJavaBuild AutomationProject ManagementPackage ManageraptdnfEnvironment VariablesPATHM2_HOMEmvn -versiontar.gzBinary Distribution
Smart Objects17 Β· 11 links
CompanyΒ· 1
ProductsΒ· 2
ConceptsΒ· 9
MediaΒ· 1
LocationsΒ· 4