Oracle JDK installation on Ubuntu

Oracle JDK installation on ubuntu


# mkdir /opt/java

# cd /opt/java

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz
# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jre-8u112-linux-x64.tar.gz

# tar -xvf jdk-8u112-linux-x64.tar.gz
# tar -xvf jre-8u112-linux-x64.tar.gz

# rm  jdk-8u112-linux-x64.tar.gz
# rm  jre-8u112-linux-x64.tar.gz

# nano /etc/profile
(Add below lines at the end of the file and save it)

JAVA_HOME=/opt/java/jdk1.8.0_112
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

JRE_HOME=/opt/java/jre1.8.0_112
PATH=$PATH:$JRE_HOME/bin
export JRE_HOME
export PATH

# update-alternatives --install "/usr/bin/java" "java" /opt/java/jdk1.8.0_112/bin/java 100
# update-alternatives --install "/usr/bin/java" "java" /opt/java/jre1.8.0_112/bin/java 100

# update-alternatives --set java /opt/java/jdk1.8.0_112/bin/java
# update-alternatives --set java /opt/java/jre1.8.0_112/bin/java

# . /etc/profile

# java -version

Note: Make sure no other vendor java is installed on your system before you start installation.
(Use # java -version to check and  # apt-get purge "installed java" to remove)
Reference

Comments