How to Install JAVA 8 (JDK 8u45) on Linux Systems

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Hosting referral link if you planning to start your blog ($3.82/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

34 Responses

  1. Amit says:

    Hi Guys, Here I am writing some simple steps to install JAVA JDK AND JRE on Linux systems.

    First download jdk-8u112-linux-x64.tar.gz and jre-8u112-linux-x64.tar.gz

    Note: Here I am sharing my Java installation instructions, which I have done in my Linux system using root user account or sudo privileges will also work.

    1. Switch to root user.

    amit@Deepin:~$sudo -i
    [sudo] password for amit: *******  
    {after this you will reach into root privileged}
    

    2. Create one folder where you would like to copy your both JDK and JRE software, In my case I place my software in /usr/local/java directory.

    So after downloading go into downloading directory folder mostly it will be: /home/amit/Downloads – in your case username will be yours.

    root@Deepin:~# cd /home/amit/Downloads
    root@Deepin:~# ls    
    jre-8u112-linux-x64.tar.gz	jdk-8u112-linux-x64.tar.gz
    

    3. Now copy both jdk and jre into your desire system location:

    root@Deepin:~# mkdir /usr/local/java
    root@Deepin:~#cp jre-8u112-linux-x64.tar.gz /usr/local/java
    root@Deepin:~#cp jdk-8u112-linux-x64.tar.gz /usr/local/java
    

    4. Extract the content of both files.

    root@Deepin:~#cd /usr/local/java
    root@Deepin:~#tar zxvf jre-8u112-linux-x64.tar.gz
    root@Deepin:~#tar zxvf jdk-8u112-linux-x64.tar.gz
    

    Verify the contents

    root@Deepin:~#ls
    jdk1.8.0_112 	jdk-8u112-linux-x64.tar.gz
    jre1.8.0_112 	jre-8u112-linux-x64.tar.gz
    

    5. Now set tha Java environment variables.

    root@Deepin:~# gedit /etc/profile

    At the bottom you just copy and paste below lines.

    unset _JAVA_OPTIONS
    JAVA_HOME=/usr/local/java/jdk1.8.0_112
    JRE_HOME=/usr/local/java/jre1.8.0_112
    PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
    export JAVA_HOME
    export JRE_HOME
    export PATH
    
    Else, if only JDK installation Require
    
    unset _JAVA_OPTIONS
    JAVA_HOME=/usr/local/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
    

    Now just save and close page:

    6. After this perform some commands in terminal.

    root@Deepin:~# update-alternatives --install "/usr/bin/java" "java" /usr/local/java/jre1.8.0_112/bin/java" 1
    root@Deepin:~# update-alternatives --install "/usr/bin/javac" "javac" /usr/local/java/jdk1.8.0_112/bin/javac" 1
    root@Deepin:~# update-alternatives --install "/usr/bin/javaws" "javaws" /usr/local/java/jre1.8.0_112/bin/javaws" 1
    root@Deepin:~# update-alternatives --set java /usr/local/java/jre1.8.0_112/bin/java
    root@Deepin:~# update-alternatives --set javac /usr/local/java/jdk1.8.0_112/bin/javac
    root@Deepin:~# update-alternatives --set javaws /usr/local/java/jre1.8.0_112/bin/javaws
    root@Deepin:~# . /etc/profile
    root@Deepin:~#
    

    7. Finally, you can check java version, JAVA HOME, and JRE Home. PATH.

    root@Deepin:~# echo $HOME
    /root
    


    root@Deepin:~# echo $PATH
    /u01/app/oracle/product/11.2.0/xe/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/java/jdk1.8.0_112/bin:/usr/local/java/jre1.8.0_112/bin

    root@Deepin:~# echo $JAVA_HOME
    /usr/local/java/jdk1.8.0_112
    root@Deepin:~# echo $JRE_HOME
    /usr/local/java/jre1.8.0_112
    root@Deepin:~# java -version
    java version "1.8.0_112"
    Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
    Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
    

    Thanks..

  2. Arpit Semwal says:

    ‘java -version’ command still shows the previous version.

  3. lothmas says:

    really cool, thanks a lot. this saved me a lot of time

  4. Cristian says:

    This is great, I always come back to this

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 300K+ Linux Users
  1. 202,035
  2. 9,267
  3. 38,621

Are you subscribed?