The easiest way to install Oracle JDK in ubuntu is through terminal.
Just run some commands and you are good to go.
- Add a ppa repository
sudo add-apt-repository ppa:webupd8team/java
- Sync local repo with newly added ppa repo.
sudo apt-get update
- Install JDK of your choice ranging from JDK 6 to 9
sudo apt-get install oracle-java6-installer sudo apt-get install oracle-java7-installer sudo apt-get install oracle-java8-installer sudo apt-get install oracle-java9-installer
but remember after installing JDK based on version it may be set as default JDK, still you can set/change default JDK by running below commands.
For those having problem with installing JDK 6/7 i.e 404-Not Found or Unable to download, you can download JDK 6/ JDK 7 from Oracle website and keep the downloaded file in the following location based on JDK you are trying to install
and trying the above commands again, you will be able to install them again.
sudo apt-get install oracle-java6-set-default sudo apt-get install oracle-java7-set-default sudo apt-get install oracle-java8-set-default sudo apt-get install oracle-java9-set-default
If you have already installed java other than oracle or want to use a java already installed in your system from the available java, you can run below command and choose the appropriate java of your choice.
sudo update-alternatives --config java