title: How to install Maven 3 on Ubuntu 18.04/17.04/16.10/16.04 LTS/15.10/15.04/14.10/14.04 LTS/13.10/13.04 by using apt-get?
body: <p>Try:</p>
  
  <pre><code>sudo apt-get install maven
  </code></pre>
  
  <p>If it works for you ignore the rest of this post.</p>
  
  <h2>Intro</h2>
  
  <p>I started setting up my Ubuntu 12.10 on April 2013 and the normal  <code>sudo apt-get install maven</code> was not working for maven 3 back then. </p>
  
  <p>The <strong>manual installation</strong> in this post is useful if you like to dig in deeper to your ubuntu kernel in regards with apt-get and where it finds the list of applications that are available for installation on Ubuntu
  . It can also be potentially useful for more recent releases of Ubuntu like <strong>Ubuntu 15.04</strong>, etc. if you face the same problem as I did back then with Ubuntu 12.10. </p>
  
  <h2>Automatic Installation via apt-get:</h2>
  
  <p>Checkout the <strong>manual installation</strong> if your current ubuntu can not install maven via common 'apt-get install maven'.</p>
  
  <pre><code>sudo apt-get update
  sudo apt-get install maven
  </code></pre>
  
  <p>Make sure to remove maven 2 if your ubuntu is not fresh or if you were using maven 2 before:</p>
  
  <pre><code>sudo apt-get remove maven2
  </code></pre>
  
  <h2>Manual Installation via apt-get by adding maven 3 repository (Ubuntu 14.04 check out update 1):</h2>
  
  <p>This can be useful if your ubuntu apt-get repositories list is not up to date.</p>
  
  <p>Maven 3 was required to set up the system and as it turns out most of the documents out there are referring to how to install Maven to Ubuntu version 12.04 or before. Best document I found was:</p>
  
  <p><a href="http://killertilapia.blogspot.com.au/2012/10/installing-maven-3-in-ubuntu-1204.html" rel="noreferrer">killertilapia's blog</a></p>
  
  <p>The whole process I came up with is as follows:</p>
  
  <ol>
  <li><code>sudo -H gedit /etc/apt/sources.list</code></li>
  <li><p>Add the following line the <code>sources.list</code> file:</p>
  
  <blockquote>
    <p>deb <a href="http://ppa.launchpad.net/natecarlson/maven3/ubuntu" rel="noreferrer">http://ppa.launchpad.net/natecarlson/maven3/ubuntu</a> precise main </p>
    
    <p>deb-src <a href="http://ppa.launchpad.net/natecarlson/maven3/ubuntu" rel="noreferrer">http://ppa.launchpad.net/natecarlson/maven3/ubuntu</a> precise main</p>
  </blockquote></li>
  <li><p><code>sudo apt-get update &amp;&amp; sudo apt-get install maven3</code></p></li>
  <li><code>sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn</code></li>
  </ol>
  
  <blockquote>
    <p>Caution 1: command "sudo apt-add-repository ppa:natecarlson/maven3" did not work on my  Ubuntu and had to run <code>sudo apt-add-repository -rm ppa:natecarlson/maven3</code> to get my apt-get to work again.</p>
    
    <p>Caution 2: thanks to David, you need to remove your existing symbolic link to previous versions of maven before running step 4.</p>
  </blockquote>
  
  <h2>OS X Installation</h2>
  
  <p>I decided to add OS X installation in case you use multiple environments for your dev: <a href="https://stackoverflow.com/questions/8826881/maven-install-on-mac-os-x">See the source stackoverflow thread for more details</a>.</p>
  
  <p>Install <a href="http://brew.sh/" rel="noreferrer">Homebrew</a> that is the equavalent of <code>apt-get</code>, then install Maven using:</p>
  
  <pre><code>brew install maven
  </code></pre>
  
  <h2><strong>Update 1</strong>: <strong>Installation for Ubunutu 14.04</strong></h2>
  
  <p>Haven't tried this myself but I am confident this should work without security warnings:</p>
  
  <pre><code>sudo apt-get purge maven maven2 maven3
  sudo apt-add-repository ppa:andrei-pozolotin/maven3
  sudo apt-get update
  sudo apt-get install maven3
  </code></pre>
  
  <p><strong>Note</strong>: source <a href="https://launchpad.net/~andrei-pozolotin/+archive/ubuntu/maven3" rel="noreferrer">here</a>, many thanks and +1s to @rendybjunior, @Dominic_Bartl, and @FunThomas424242 </p>