How do I install Maven 3?

Maven3 is the default in Ubuntu 12.04 (precise)

Maven2 is the latest in the repositories for 11.10.

PPAs for maven3 seem rather scarce - here is one for maverick - although not the very latest version available.

The best advice is to stay with the stable version available for your distro version.

However if you like to keep up-to-date yourself it is very straightforward to download the code and install yourself.

Download the .tar.gz file from here and follow the installation guidance on the same web-page


Here is a maven3 PPA that worked fine for me on 64 bit Ubuntu 11.10

sudo add-apt-repository ppa:natecarlson/maven3
sudo apt-get update && sudo apt-get install maven3

If you have maven2 already installed from canonical repos this will not replace it but give you a mvn3 binary.

If you prefer to have the binary called mvn instead of mvn3 you can simply do the following:

sudo ln -s /usr/bin/mvn3 /usr/bin/mvn

Source


The question is old, but gold. I had to find a solution today. Here we go. There is no need to use an unsecure repository, because maven3 is already included in the Ubuntu repos. A solution at Ubuntu 14.04 LTS will be like:

  • sudo apt-get install maven
  • sudo update-alternatives --config mvn

With the 2nd command you're asked to set the used version. You can distinguish the correct directories by selecting the path where maven2 is NOT part of it.

   *0    /usr/share/maven2/bin/mvn   200       Auto-Modus
    1    /usr/share/maven/bin/mvn    150       manueller Modus
    2    /usr/share/maven2/bin/mvn   200       manueller Modus

In my case I had to select 1

With the issued command mvn -v you may verify, if the setting succeeded and whether you selected the correct version. Below you have an example of the returned values.

  ~$ mvn -version
  Apache Maven 3.0.5
  Maven home: /usr/share/maven
  Java version: 1.7.0_75, vendor: Oracle Corporation
  Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
  Default locale: de_DE, platform encoding: UTF-8
  OS name: "linux", version: "3.13.0-45-generic", arch: "amd64", family: "unix"

Hope this helps you a bit.