Java Language Installing oracle java on Linux with latest tar file


Example

Follow the below steps to install Oracle JDK from the latest tar file:

  1. Download the latest tar file from here - Current latest is Java SE Development Kit 8u112.

  2. You need sudo privilages:

    sudo su
    
  3. Create a dir for jdk install:

    mkdir /opt/jdk
    
  4. Extract downloaded tar into it:

    tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk
    
  5. Verify if the files are extracted:

    ls /opt/jdk
    
  6. Setting Oracle JDK as the default JVM:

    update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100
    

    and

    update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100
    
  7. Check Java version:

    java -version

Expected output:

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)