In this blog post, I will show you how to remove openjdk and install oracle jdk on ubuntu.
Step-1: Download oracle JDK
Download from here
Step-2: Remove existing openjdk
sudo apt-get purge openjdk-\*
Step-3: Create directory for java installation
sudo mkdir -p /usr/local/java
Step-4: Copy & unzip to the install directory
sudo cp -r jdk-8u21-linux-x64.tar.gz /usr/local/java/
sudo tar xvzf jdk-8u21-linux-x64.tar.gz
Step-5: Setup path in bashrc
JAVA_HOME=/usr/local/java/jdk1.8.0_21 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH
Step-6: Update alternatives for run time
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_21/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_21/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_21/bin/javaws" 1
Step-7: Update alternatives for jdk
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_21/bin/java sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_21/bin/javac sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_21/bin/javaws
Step-8: Refresh profile
source /etc/profile