January 9, 2013

How to Install Maven 3 on RHEL 6.3

In RHEL 6 there is no package for Apache Maven 3 and if you search the official repo you will end up with.

$ yum search maven
...
jpackage-utils.noarch : JPackage utilities

But that package does not contain any maven binaries. So since there is no official package and I do not want to clutter my RHEL installation, by adding custom repositories, we will do it manually. And that is no big thing.

First download the apache maven binaries, I downloaded the zip file. And extract it in /usr/share.

$ unzip /home/magkar/Downloads/apache-maven-3.0.4-bin.zip -d /usr/share/

Now "install" it, i.e. create a soft link.

$ ln -s /usr/share/apache-maven-3.0.4/bin/mvn /usr/bin/mvn

And finally set all needed environment variables in /etc/environment. And for my RHEL 6.3 machine they look like this.

JAVA_HOME=/usr/lib/jvm/java
M2_HOME=/usr/share/apache-maven-3.0.4

Now test your installation of Apache Maven 3.0.4.

$ mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/share/apache-maven-3.0.4
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-279.19.1.el6.x86_64", arch: "amd64", family: "unix"

No comments: