Ubuntu comes with an opensource java installed. To use the oracle’s java, you need to remove the openjkd and install oracle’s.
First we need to remove the openjdk from Ubuntu.
1sudo apt-get purge openjdk*
Then add webupd8team repository, since Oracle still don’t have an official repository.
1sudo add-apt-repository ppa:webupd8team/java
2sudo apt-get update
After the update finished, we can install java via:
1sudo apt-get install oracle-java8-installer