Install latest maven on Ubuntu
Maven Installation
Get the latest maven from https://maven.apache.org/download.cgi
Choose a binary zip or tar archive (see Link header) and download with
wget https://downloads.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip
Unzip and move to
/usr/local/
unzip apache-maven-3.8.3-bin.zip
sudo mv apache-maven-3.8.3 /usr/local
add to path and reopen terminal
export PATH=/usr/local/apache-maven-3.8.3/bin:$PATH
or
ln -s /usr/local/apache-maven-3.8.3/bin/mvn /usr/bin/mvn
mvn version check
$ mvn -version
Apache Maven 3.8.3 (...)
Maven home: /usr/local/apache-maven-3.8.3
Java version: 1.8.0_292, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-18362-microsoft", arch: "amd64", family: "unix"
[1] https://maven.apache.org/install.html
[2] https://maven.apache.org/download.cgi
Troubleshooting
1 Command 'unzip' not found
$ unzip apache-maven-3.8.1-bin.zip
Command 'unzip' not found, but can be installed with:
sudo apt install unzip
for installing unzip
,
do:
sudo apt update
sudo apt install unzip
2 The JAVA_HOME environment variable is not defined correctly
$ mvn -version
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
3 check for java
Install Java as per the instructions in the next section.
Java Installation
$ java -version
Command 'java' not found, but can be installed with:
sudo apt install openjdk-11-jre-headless # version 11.0.11+9-0ubuntu2~20.04, or
sudo apt install default-jre # version 2:1.11-72
sudo apt install openjdk-8-jre-headless # version 8u292-b10-0ubuntu1~20.04
sudo apt install openjdk-13-jre-headless # version 13.0.4+8-1~20.04
sudo apt install openjdk-14-jre-headless # version 14.0.2+12-1~20.04
for installing java:
sudo apt update
sudo apt install openjdk-8-jdk-headless
use JDK not JRE. i.e., openjdk-8-jdk-headless instead of openjdk-8-jre-headless otherwise you would come across an error like: Unable to find javadoc command:The javadoc executable '/usr/lib/jvm/java-11-openjdk-amd64/bin/javadoc'
Video
Run through of commands
Last updated
Was this helpful?