Home

Manual Oracle JDK installation on Ubuntu

This memo describes how to manually install an Oracle JDK on Ubuntu 13.10. Its also works for 14.04.

The first step is to download the desired Oracle JDK as .tar.gz file from the oracle.com website. Afterwards extract the downloaded file.

cd /usr/lib/jvm
wget http://oracle.com/.../myjdk.tar.gz
tar xf myjdk.tar.gz

Install and config

Use update-alternatives to create symbolic links to the new JDK.

The 1 in the end is the priority. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority.

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/myjdk/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/myjdk/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/myjdk/bin/javaws" 1
sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/myjdk/bin/jar" 1

# The following is obsolete if there are no alternatives

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
sudo update-alternatives --config jar

Firefox Plugin

cd /usr/lib/mozilla/plugins # ~/.mozilla/plugins/ is also possible
ln -s /usr/lib/jvm/myjdk/jre/lib/i386/libnpjp2.so libnpjp2.so

Final steps and verification

Set a symlink for the $JAVA_HOME variable with the following command.

sudo ln -s /usr/lib/jvm/myjdk /usr/lib/jvm/jdk1.7.0

Globally create the JAVA_HOME system environment variable with

vi /etc/profile

... and add the following

export JAVA_HOME="/usr/lib/jvm/jdk1.7.0"
# ... and more stuff if you like for example maven opts
export MAVEN_OPTS="-Xmx2G -XX:MaxPermSize=1G"

To verify everything went well execute the following commands.

java -version
javac -version

Date published:
Date modified: 2014-04-16
Keywords: Linux, JDK, ubuntu