How to install maven on OpenSUSE

By default OpenSUSE Linux distribution doesn't have Maven into its repositories because of tons of dependencies which needed for Maven. But in spite of this Maven installation is straightforward in OpenSUSE.

In this tutorial I will show how to install Maven from its official web site.

First of all we need to download Maven from the official web site. There 2 types of archives there: tar.gz and zip.
In this tutorial we will install Maven from the tar.gz archive.

To download maven we will use wget. Insure that it's already installed into the system.

All commands listed bellow will be entered into command prompt (console, terminal) from a regular user(not root).

  • Download archive:

If nothing was entered after opening terminal the archive will be downloaded into the User's home folder.

  • Unzip archive into the opt folder:
sudo apache-maven-3.3.9-bin.tar.gz -C /opt

As a result Maven will be extracted into the /opt/apache-maven-3.3.9 folder.

  • Rename folder apache-maven-3.3.9 to maven:
sudo mv /opt/apache-maven-3.3.9 /opt/maven
  • To use maven from the console (terminal) we need to edit the .bashrc file and add the following lines:
# =======  maven settings =========
export M2_HOME=/opt/maven/
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
  • Reload .bashrc:
source ~/.bashrc
  • Verify that everything works correct:
mvn -v

The output should look like this:

Apache Maven 3.3.9 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T23:58:10+03:00)
Maven home: /opt/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib64/jvm/java-1.7.0-openjdk-1.7.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.11.10-21-desktop", arch: "amd64", family: "unix"

Alexey Bogdanov

Read more posts by this author.

Subscribe to Development notes

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!