Upgrade existing Maven installation to latest

Eddie Rantsimele
1 min readJan 17, 2024

--

When moving to JDK 21 in an old project running Maven 3.6.0, we encountered build failures. This was due to our Maven installation being incompatible with JDK 21, the issue was solved by upgrading Maven to the latest stable version.

In this tutorial we will working in bash terminal on Debian/ Ubuntu, we assume that you have an older version of Maven already installed.

  1. Locate your current Maven installation
mvn -version

or

echo $M2_HOME

2. Remove Maven directory at current location (in my case /usr/share/maven)

sudo rm -rf /usr/share/maven

3. Download and extract Maven from repository (update link binary as appropriate)

wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
tar -xvf apache-maven-3.9.6-bin.tar.gz

4. Move Maven artifact to /opt directory

mv apache-maven-3.9.6 /opt

5. Add Maven to PATH and change location of M2_HOME (view linked video)

6. Source to .bashrc or open new terminal to view changes

source ~/.bashrc

7. Maven should be updated to latest

The steps above should get you a JDK 21 compatible version of Maven, from an older installation. Happy building.

--

--

Eddie Rantsimele
Eddie Rantsimele

Written by Eddie Rantsimele

Java, JavaScript, Rust, Python, NodeJS, Kubernetes, Openshift, AWS and Azure

Responses (1)