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.