How to update maven 3.0.4 - 3.1.1
Solution 1
To upgrade single package in terminal:
sudo apt-get --only-upgrade install maven
To Install downloaded package of maven apache-maven-3.1.1-bin.tar.gz
cd ~/Downloads
wget http://apache.mirrors.timporter.net/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
sudo mkdir -p /usr/local/apache-maven
sudo mv apache-maven-3.1.1-bin.tar.gz /usr/local/apache-maven
cd /usr/local/apache-maven
sudo tar -xzvf apache-maven-3.1.1-bin.tar.gz
Edit ~/.profile with gedit ~/.profile
and add these four lines:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1 export M2=$M2_HOME/bin export MAVEN_OPTS="-Xms256m -Xmx512m" export PATH=$M2:$PATH
don't forget to execute following command to have the update without restarting the machine
source ~/.profile
Solution 2
On the basis the original question asked about the latest version of Maven this PPA provides a backport from wily
to trusty
for Maven 3.3.9
https://launchpad.net/~andrei-pozolotin/+archive/ubuntu/maven3
Instructions to use this PPA are copied from the link above.
sudo apt-get purge maven maven2 maven3 sudo add-apt-repository ppa:andrei-pozolotin/maven3 sudo apt-get update sudo apt-get install maven3
This worked fine for me on Ubuntu 14.04.3 LTS
. The installed command was mvn
without any need to add a symlink.
$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /usr/share/maven3
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-33-generic", arch: "amd64", family: "unix"
Solution 3
There is a PPA for maven with 3.1 at https://launchpad.net/~natecarlson/+archive/maven3
sudo add-apt-repository ppa:natecarlson/maven3
The only problem is that the command-line tool from the PPA is maven3, which is going to break any scripts calling mvn.
sudo ln -s /usr/bin/maven3 /usr/bin/mvn
Solution 4
To install mvn3 on Ubuntu 14.04, run:
sudo apt-get purge maven maven2 maven3
sudo add-apt-repository ppa:andrei-pozolotin/maven3
sudo apt-get update
sudo apt-get install maven3
To make a symbolic link, run:
sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn
Reference: https://launchpad.net/~andrei-pozolotin/+archive/ubuntu/maven3
Solution 5
I found this guide worked best for Ubuntu 14.04 to upgrade maven to 3.2.1 http://linuxg.net/how-to-install-apache-maven-3-2-1-on-ubuntu-14-04-linux-mint-17-and-their-derivative-systems/
First, remove the previous mavens of maven, do:
sudo apt-get remove maven*
Install Maven 3:
sudo apt-get install gdebi
wget http://ppa.launchpad.net/natecarlson/maven3/ubuntu/pool/main/m/maven3/maven3_3.2.1-0~ppa1_all.deb
sudo gdebi maven3_3.2.1-0~ppa1_all.deb
Symlink it, for an easier usage:
sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/maven
Related videos on Youtube
suja
Updated on September 18, 2022Comments
-
suja almost 2 years
First of all am new to Ubuntu as well as Maven. Does anyone know how to update maven. My current version of maven is 3.0.4. I would like to update it to 3.1.1 which is the latest version. I tried
sudo apt-get update maven
but this didn't help much. Any suggestion. Am using maven for first time. Also how to install
apache-maven-3.1.1-bin.tar.gz
I know there is an command like
sudo apt-get install maven
but it will download maven and then install it.. Since I may need to install maven on a few systems downloading it each time won't be a better option for us. So I am looking forward answer for two questions
How to update installed maven
How to install downloaded package of maven apache-maven-3.1.1-bin.tar.gz
-
lemonsqueeze about 7 yearsPossible duplicate of Gradle in Ubuntu for Launchpad
-
lemonsqueeze about 7 yearsEasiest is probably to use sdkman.
-
suja over 10 yearsis ' sudo apt-get --only-upgrade install maven ' upgrade maven to latest version 3.1.1 coz i tried it and still its 3.0.4
-
Mina Eid over 10 yearsupdate your package list first with sudo apt-get update
-
Mina Eid over 10 yearsif it doesn't work, try with wget
-
david.perez over 9 yearsThis solution looks like good, but doesn't work with recent versions of Ubuntu, like 14.04.
-
rofrol over 9 yearsoutdated: latest version on ~natecarlson is 3.2.1, while latest version of maven is 3.2.5
-
Stoffe over 9 yearsThere's a PPA for Utopic at: launchpad.net/~vkorenev/+archive/ubuntu/maven3
-
Stoffe over 9 yearsAlso, a variation on the linking is to use update-alternatives:
sudo update-alternatives --install "/usr/bin/mvn" "mvn" "/usr/share/maven3/bin/mvn" 1
then switch withsudo update-alternatives --config mvn
-
ZiglioUK about 9 yearsW: Failed to fetch ppa.launchpad.net/natecarlson/maven3/ubuntu/dists/utopic/main/… 404 Not Found
-
David Baucum about 9 years@ZiglioNZ: That PPA only works for Lucid - Precise and is outdated even if you are running one of those versions.
-
ZiglioUK about 9 yearsThank you, I used ppa.launchpad.net/vkorenev/maven3/ubuntu
-
Madhavan about 9 yearsi tried sudo apt-get update && sudo apt-get --only-upgrade install maven.. as suja's comment says, it does not update my maven to 3.1.1. it is still 3.0.4
-
logoff about 9 yearsit would be much better using the PPA repository as is, not downloading debs to install them manually. see @david-baucum answer: askubuntu.com/questions/420281/…
-
Marko Bonaci about 9 years@MadhavanKumar that's because the last version published in
apt
is3.0.4
. You can always check that withsudo apt-get update
to refresh your local cache; thenapt-cache search maven
and finallyapt-cache showpkg <name-of-the-package>
to see the current version. -
Kenneth Worden almost 9 yearsDoes anyone know if Apache is going to update Maven on the Ubuntu repos? The package they host on the default repos still has bugs and it's been over a year.
-
Archimedes Trajano over 8 yearsThe natecarleson/maven3 is out of date and hasn't been updated for 80+ weeks now.
-
David Edwards over 8 yearsIt is worth noting that although a PPA might not support an older version of Ubuntu, that doesn't mean the packages won't work. For example, I just downloaded Maven 3.3.9 from launchpad.net/~andrei-pozolotin/+archive/ubuntu/maven3 and installed it on Ubuntu 12.04 using
dpkg
and it is working just fine. -
Arul over 8 yearssame way you can download deb for Maven 3.3.9 from ppa.launchpad.net/andrei-pozolotin/maven3/ubuntu/pool/main/m/…
-
matanster about 8 yearsThis is probably the more contemporary solution to use. Many thanks.
-
user1159819 about 8 yearsThe simplest and cleanest solution, no symbolic links to create. Thank you!
-
user1159819 about 8 yearsThis answer is now dated. The simplest and cleanest solution is the newer answer by Janek Bogucki below.
-
Reinier Post almost 8 yearsAlways mention your Ubuntu version!! 14.04 still has 3.0.x, 16.04 has 3.3.x (ight now)
-
vefthym over 7 yearsThe methodology is NOT outdated, only the maven version. Simply change 3.1.1 to the current version, and it works fine. I successfully did that with maven 3.3.9
-
Vasil Valchev over 7 yearsE: Unable to locate package maven3
-
Matt Korostoff about 7 yearsGreat answer, I've been trying to make this work all day, thanks!
-
DavidPostill about 7 yearsPlease do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
-
TomRed about 7 years@DavidPostill fair enough. But these are the questions that I searched and didn't find a useful answer on that is why I linked them together. Maybe when I build the reps I will do the duplicate but in the mean time I will raise a flag. Thanks for the advise.