Saturday, October 13, 2012

Installing Maven 3 in Ubuntu 12.04 Precise

Ubuntu needs to no explanation and Maven is software project management tool. It manages software dependencies and how your code is compiled and deployed. Its pretty handy because now I don't have to hunt down jars that my other jars need and no more copying the binaries to target folders.

Unfortunately, the Ubuntu repos are a bit slow. The repos only have Maven2. Now, let's get to installing Maven3.

1. Install the Nate Carlson's PPA for Maven3
2. Open a terminal console and type in: sudo apt-get update
3. After update finishes, type in: apt-get install Maven3

You now have Maven3 installed but you can't run it from the terminal because you didn't set the paths. If you try to type: mvn --version; That should fail. To fix this you have to make a symbolic link from where Maven3 is installed to where it can be run it "globally" from the terminal.

$ sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn

You just created a symbolic link in /usr/bin/mvn. The mvn command now should work in your terminal.

Update (3/29/2013):
Caution: command "sudo add-apt-repository ppa:natecarlson/maven3" did not work on my Ubuntu and and had to run "sudo add-apt-repository -rm ppa:natecarlson/maven3" to get my apt-get to work again. ~AmirHD
See this Stackoverflow thread.

7 comments:

  1. sudo apt-get install maven3 //tdert ka

    ReplyDelete
  2. This is not working for ubuntu 12.10. I got the error Unable to locate package Maven3 or Unable to locate package maven3

    ReplyDelete
    Replies
    1. Did you to install Nate Carlson's PPA first before you ran apt-get install maven3?

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This approach doesn't seem to be working always.

    See http://stackoverflow.com/questions/15630055/how-to-install-maven-3-on-ubuntu-12-10-by-using-apt-get/ to find a way around.

    ReplyDelete
    Replies
    1. Thanks. I will update the entry with the new information.

      Delete