Maven - Install the mvn CLI on Linux

by
Jeremy Canfield |
Updated: August 17 2024
| Maven articles
The wget command can be used to download the mvn TAR archive.
wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
The tar command can be used to extract the TAR archive.
tar -zxpf apache-maven-3.9.9-bin.tar.gz --directory /tmp
The TAR file can be deleted.
rm apache-maven-3.9.9-bin.tar.gz
The extracted TAR archive should contain a few files and directories.
~]$ ll /tmp/apache-maven-3.9.9/
total 36
drwxr-xr-x. 2 john.doe admins 97 Aug 21 20:09 bin
drwxr-xr-x. 2 john.doe admins 76 Aug 21 20:09 boot
drwxr-xr-x. 3 john.doe admins 63 Aug 14 03:48 conf
drwxr-xr-x. 4 john.doe admins 4096 Aug 21 20:09 lib
-rw-r--r--. 1 john.doe admins 18920 Aug 14 03:48 LICENSE
-rw-r--r--. 1 john.doe admins 5034 Aug 14 03:48 NOTICE
-rw-r--r--. 1 john.doe admins 1279 Aug 14 03:48 README.txt
The mvn CLI requires the JAVA_HOME variable to point to a Java Development Toolkit (JDK) installation.
The mvn CLI should return the version of Maven you installed.
~]# /tmp/apache-maven-3.9.9/bin/mvn --version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/apache-maven-3.9.9
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"
Did you find this article helpful?
If so, consider buying me a coffee over at