In order to update to the latest java version on Ubuntu you need to download the latest tar ball from the Java website www.java.com
Unzip this using the command:
tar zxvf jdk-8u66-linux-x64.tar.gz -C /usr/java
Next tell the system that there is a new java version:
update-alternatives --install "/usr/bin/java" "java" "/usr/java/jre1.8.0_66/bin/java" 1
Now set this JDK/JRE as default:
update-alternatives --set java /usr/java/jre1.8.0_66/bin/java
Now check the version:
java -version
Updating Java to latest version on Ubuntu