Given that Oracle does not have a release for Ubuntu platform, one way to seamlessly install the latest version is
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$sudo apt-get install oracle-java7-installer
Added after inputs from Kiran for Centos
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-x64.rpm"
Added after inputs from Kiran for Centos
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-x64.rpm"