Installing Java 8 on ubuntu

  1. Check if java is already present
     java-version 
  2. If open jdk is present remove it by using
    sudo apt-get purge openjdk* 
  3. Now add the repository, update it and install java 8
    sudo add-apt-repository ppa:webupd8team/java
    
    sudo apt-get update
    
    sudo apt-get install oracle-java8-installer
    
    
  4. Lastly , set the environment variables. I would suggest you to use defaults 🙂  
    sudo apt-get install oracle-java8-set-default