java install from a tar

Download the linux tar.gz for jdk

mkdir -p /usr/java
tar xvzf jdk-8u5-linux-i586.tar.gz -C /usr/java

Put a global env setting

vi /etc/bash.profile

EXPORT JAVA_HOME=/usr/java/jdk_1.8.0_144/

Now setup alternative options

update-alternatives --install /usr/bin/java java /usr/java/jdk_1.8.0_144/bin/java 20000
update-alternatives --install /usr/bin/javac javac /usr/java/jdk_1.8.0_144/bin/javac 20000

You may have to do this

update-alternatives --config java

To test

java -version