#Check Linux version
uname -a
#Download appropriate binaries from Oracle site
#http://www.oracle.com/technetwork/java/javase/downloads/index.html
#Choose Linux x64 e.g. jdk-6u45-linux-x64.bin
#Remove java
sudo apt-get purge openjdk-\*
sudo apt-get remove --purge sun-java6-jdk
#Create java dir
sudo mkdir -p /usr/local/java
#Copy java to the newly created java dir
chmod a+x jdk-XuYY-linux-x64.bin
#extract
./jdk1.6.0_45-linux-x64.bin
#include java in system environment
vi /etc/profile
JAVA_HOME=/usr/local/java/jdk1.6.0_45
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH
#
update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.6.0_45/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.6.0_45/bin/javac" 1
#reload environment
./etc/profile
#Check version
java -version
javac -version