Although there is an option to install Java and JDK with aptitude, the version is a bit old, i.e. version 7 instead 8. I have no option but do it manually.
Here are the steps which I tool to install JDK8 on my machine.
1) Download your JDK8 from Oracle. Since I am using Debian, I picked and used the gzip version.
2) Decompress the gzip file, e.g.
tar zxvf jdk-8u60-linux-i586.tar.gz
3) Move the uncompressed package to your desired location. In my case, I put it where other OpenJDK are located, e.g.
sudo mv jdk1.8.0u60 /usr/lib/jvm
4) Create a subversion mutual symbolic link to the /usr/lib/jvm/jdk1.8.0u60, e.g.
ln -s /usr/lib/jvm/jdk1.8.0u60 /usr/lib/jvm/oracle-jdk8
5) Use update-alternative to add java, javaws, javadoc, javac to the system.
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/oracle-jdk8/bin/java" 1
Repeat the above for javac, javadoc and javaws
6) You may need to use update-alternatives --config to update the default java executable path, e.g.
update-alternatives --config java
7) Test you setup by running
java -version
(see: http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre)
8) If you have NetBeans setup before the installation, you need to update its java_homepath value by modifying its netbeans.conf file.
I kept the configuration personalized to my account, hence I used the localized version which is at:
~/.netbeans/
The contents in my netbeans.conf is
netbeans_jdkhome=/usr/lib/jvm/oracle-jdk8
note: You may not see the etc directory. If you can't see it, you need to create the etc directory and .netbeans.conf file yourself.
(further information can be found at: Netbeans - ArchWiki)
Update 2016-01-28: Alternatively, Java can be installed with APT by following the instructions at:
https://launchpad.net/~webupd8team/+archive/ubuntu/java
and
https://launchpad.net/~webupd8team/+archive/ubuntu/java