-
Notifications
You must be signed in to change notification settings - Fork 0
Maven Installation: Linux
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 have already put Maven in Ubuntu's apt-repositories by factory default.
Let's get to it. First update your sources, just in case:
sudo apt-get update
Once that's 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 congratulations! 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 approach, 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. For the sake of the tutorial, though, it'd be best to use the same editor, so no confusion arises.
Step 1: Add the sources to your sources.list:
nano /etc/apt/sources.list
And add 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 nano by pressing Ctrl-X.
Step 2: Update sources and install maven3:
sudo apt-get update
sudo apt-get install -y maven3
Step 3: Good! Now all that's left is to add a symbolic link for maven, so lets do that:
ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn
Alright. That's all there is to it! Check that your current Maven installation is working by doing
mvn -version
If your returned version is Maven 3.x.x, you've successfully installed maven3!
Let's get started. 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 step has 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 has gone well, you should be able to execute mvn -version
without any errors.
If everything is 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.