Oracle Java for Ubuntu and setting JDK for Netbeans

For those who want to install Oracle Java JDK to develop Java programs and applications (the Oracle Java JRE is also included in the Oracle JDK) use this method:

Open your terminal and type:

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Setting as default JDK

sudo apt-get install oracle-java8-set-default

Setting the path globally:

type : sudo nano /etc/bash.bashrc  and add this line at the end of page.

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

loading bash.bash.bashrc

source /etc/bash.bashrc

Now you have to configure Netbeans to use this JDK or run Netbeans with

cd /usr/local/netbeans-8.1/etc or /usr/share/netbeans/8.1/etc (this is for version 8.1)

sudo nano netbeans.conf and change the line netbeans_jdkhome=”/usr” as below