Monday, April 28, 2014

Install and configure JAVA + MAVEN in Ubuntu 14.04

It's pretty easy to install and configure JAVA + MAVEN in Ubuntu 14.04 following these steps:

1. Install OpenJDK 7:

$ sudo apt-get install icedtea-7-plugin openjdk-7-jre openjdk-7-jdk

Check the installed java:

$ java -version

It will show something like:

java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.6) (7u51-2.4.6-1ubuntu4)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

2. Configure JAVA_HOME environment variable:

  • Open the /etc/environment file:

$ sudo nano /etc/environment
$ source /etc/environment

  • Add this line:


  • Open ~/.bashrc:
$ sudo nano ~/.bashrc

  • Add these lines to the end of the file:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

export PATH=$JAVA_HOME/bin:$PATH

$ source ~/.bashrc

3. Install Maven:

$ sudo apt-get install maven

Check the installed maven's version:

$ mvn -version

It will show something like:

Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-24-generic", arch: "amd64", family: "unix"

4. Done