Installing oracle jdk on ubuntu

Ubuntu boxes have by default open-jdk wich is a great tool, some tools requires oracle jdk version in order to run properly, ie CassandraDB this post shows how to install oracle jdk on ubuntu systems

Checking the current java version installed

$ java --version
java version "1.5.0"
gij (GNU libgcj) version 4.6.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Download and Installing oracle jdk

  1. Create a directory on your local filesystem where the jdk will live $sudo mkdir -p /opt/oracle/jdk
  2. Visit Oracle website choose jdk that suit your needs and dowload it download the file with the .bin extension
  3. Change permission and execute downloaded file under /opt/oracle/jdk directory
  4. Make symbolyc links between oracle jdk executables and /etc/alternatives directory. $sudo ln -s /opt/oracle/jdk/jdk1.6.0_45/bin/java /etc/alternatives/javaoracle $sudo ln -s /opt/oracle/jdk/jdk1.6.0_45/bin/javac /etc/alternatives/javacoracle
Every time that you want want to use oracle jdk you can define an alias alias java=/etc/alternatives/javaoracle Now you can check again your java version:
 $java -version
 java version "1.6.0_45"
 Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
 Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)