Issue
I am trying to install maven in linux machine using the following command:
sudo apt install maven
But this command installs the maven version 3.6.0, whereas the latest version for maven in the apache maven web-site is 3.8.1. Any suggestions on how to install maven 3.8.1 via apt install command?
Solution
This is a small guide to install maven on ubuntu 20.04 LTS. Jul 28, 2021
Download maven from https://maven.apache.org/download.cgi click the link apache-maven-3.8.1-bin.tar.gz.
Extract the files in your downloads folder.
cd Downloads
sudo tar xzvf apache-maven-3.8.1-bin.tar.gz -C/opt/
In a terminal window enter the following.
nano .profile
Edit the file and add the following text at the bottom of the page.
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JAVA_HOME
MAVEN_HOME=/opt/apache-maven-3.8.1
export MAVEN_HOME
PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
export PATH
Now press ctrl + O to save the file, and ctrl + X to close the file.
Back in the terminal run the script with.
. .profile
Check the version of java and maven with the commands.
`java --version`
`mvn --version`
Now you should see the proper version of Maven installed.
If you open a new terminal window and the installation seems ineffective: LOGOUT AND LOGIN!!!**
Answered By - MalcolmXYZ