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 or any else ways?
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!!!**
Build it from the source. https://maven.apache.org/download.cgi
Installing Maven
Unix-based operating systems (Linux, Solaris and Mac OS X)
tar zxvf apache-maven-3.x.y.tar.gz
Windows
unzip apache-maven-3.x.y.zip
A directory called "apache-maven-3.xy" will be created.
Add the bin directory to your PATH, eg:
Unix-based operating systems (Linux, Solaris and Mac OS X)
export PATH=/usr/local/apache-maven-3.x.y/bin:$PATH
Windows
set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH%
Make sure JAVA_HOME is set to the location of your JDK
Run "mvn --version" to verify that it is correctly installed.
For complete documentation, see https://maven.apache.org/download.html#Installation
JAVA_HOME=/usr/ib/jvm/java-11-openjdk-amd64
should be JAVA_HOME=/usr/ lib /jvm/java-11-openjdk-amd64
which is the default Java 11 (OpenJDK) directory.
Following command helped me.
Remove current version:
sudo apt-get purge maven
Download the latest version:
wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
Installation:
sudo cp -r apache-maven-3.8.6 /opt
export PATH=/opt/apache-maven-3.8.6/bin:$PATH
Note : Make sure Java should install before following the above steps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.