-
Notifications
You must be signed in to change notification settings - Fork 0
Maven Installation: Linux
Maven v3 is already in the repositories (for Ubuntu at least). I think the recent versions of Ubuntu ship with maven under the 'maven' package name and so an
apt-get install maven
should just work (no need for a PPA or changing the sources file). I think it's also worth perhaps avoiding mentioning maven2 and ensuring everyone is using the latest version to prevent any issues cropping up because some people used the wrong version.
It might also be worth mentioning that the apt-get method only works with distros that actually use that packaging system (maybe different sections for popular distros - debian, ubuntu etc).
Note: We recommend you use the latest version of maven, which currently is 3.2.1, you can use other older versions, but issues may arise that are occurring due to use of an outdated version.
On Ubuntu installing maven is a piece of cake, since Canonical is nice enough to already have maven in its apt-respositories by factory default.
Let's get to it, first update your sources, just in case:
sudo apt-get update
Once thats done, install maven with apt-get:
sudo apt-get install -y maven
If everything has gone well, you should be able to do:
mvn -version
And get a response similar to this:
Apache Maven 3.2.1 (rdebian-4)
Java version: 1.7.0_55
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux" version: "2.6.32-5-amd64" arch: "amd64" Family: "unix"
If that's the case then congrats! You've successfully installed maven 3.2.1.
Since poor old Debian hasn't added maven's latest version to their apt-repositories we won't be able to do the standard apt-get approuch, but instead have to add the repositories manually.
Let's get started on installing maven3. In order to do this you'll most likely have to add a few new lines to your sources.list file. I prefer using nano
for all my editing needs, but feel free to use whatever you prefer as well. For the sake of the tutorial though It'd be best to use the same editor, so no confusion arises.
So, step 1, add the sources to your sources.list:
nano /etc/apt/sources.list
And add in these lines:
deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main
deb-src http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main
Now exit out of nano by holding Ctrl-X.
Step 2, update sources and install maven3:
sudo apt-get update
sudo apt-get install -y maven3
Good! Now all that's left is to add a symbolic link for maven, so lets do that, step 3:
ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn
Alright, that's all there is to it! Check your current maven installation is working by doing
mvn -version
If your returned version is maven 3.x.x you've successfully installed maven3!
Step 1, download the latest version of maven from Apache Maven, or use this command to download it to your current directory: (Note, if you did this make sure to remember what directory you've saved it to!)
wget 'http://tweedo.com/mirror/apache/maven/maven-3/3.2.1/binaries/apache-maven-3.2.1-bin.tar.gz' -O maven3.2.1-bin.tar.gz
Good, once that's done continue to unpack the downloaded archive to a directory of your choice, in this case I'll be putting it into
/usr/share/maven3
To do that, execute these commands while in the folder you originally saved that maven archive to:
sudo mkdir /usr/share/maven3/ && sudo tar -xzf maven3.2.1-bin.tar.gz -C /usr/share/maven3
Once that steps been completed go on to adding a symbolic link for maven:
ln -s /usr/share/maven3/apache-maven-3.2.1/bin/mvn /usr/bin/mvn
If everything until now has gone well you should be able to execute mvn -version
without any errors.
If everything working, then congratulations! You've successfully installed maven on linux!
Visit the site at tenjava.com
If you have any questions (about the contest, git, Maven etc), please don't hesitate to send us a tweet @tenjava or ask in our IRC channel.