Go to this link and download the exe file http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Then install the file and then set file path
Right click on My computer -> Properties -> Advanced system settings -> Environment variables
Click on the edit if Path variable is already there copy the path of java and it will be something like this.
C:\Program Files (x86)\Java\jdk1.8.0_20\bin
add ; before it.
If the Path variable is not there then click on new name it as path and add the path.
Then open up the cmd and type javac to check the java compiler.
Then type java if it is showing the information then you are good to go.
Open up the terminal and type sudo -i enter your password
Then sudo add-apt-repository ppa:webupd8team/java
sudo apt-get updatesudo apt-get install oracle-java8-installerTo set the environment variable sudo apt install oracle-java8-set-default
Then type javac to check the java compiler.
Then type java if it is showing the information then you are good to go.