How to Install Java 9 JDK on Linux Systems

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

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. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  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...

45 Responses

  1. Jin Xilong says:

    Hello, I am a lack experience engineer. please explain to me what is the meaning of 20000 at the end of the sentence, I could not find that at oracle official website.

    # update-alternatives --install /usr/lib/mozilla/plugins/ /opt/java/jdk-9.0.4/lib/ 20000
  2. hrx says:

    Java is only supported on Firefox ESR 52.

  3. Alejandro says:

    I get this error when write # java -version

    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object

  4. Rommel says:

    Nice article! The steps are easy to follow. This helped me alot. Thanks!

  5. tarun singhal says:

    wget –no-cookies –no-check-certificate –header “Cookie:; oraclelicense=accept-securebackup-cookie” “”

    above command giving error
    HTTP request sent, awaiting response… 404 Not Found
    2017-09-10 21:53:31 ERROR 404: Not Found.

    Please explain

    • Ravi Saive says:


      Please go to the oracle download section and download the latest version of Java and follow the instructions to install it on Linux..

  6. Sk Haider says:

    Its still showing previous version

  7. 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.

    [email protected]:~$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.

    [email protected]:~# cd /home/amit/Downloads
    [email protected]:~# 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:

    [email protected]:~# mkdir /usr/local/java
    [email protected]:~#cp jre-8u112-linux-x64.tar.gz /usr/local/java
    [email protected]:~#cp jdk-8u112-linux-x64.tar.gz /usr/local/java

    4. Extract the content of both files.

    [email protected]:~#cd /usr/local/java
    [email protected]:~#tar zxvf jre-8u112-linux-x64.tar.gz
    [email protected]:~#tar zxvf jdk-8u112-linux-x64.tar.gz

    Verify the contents

    [email protected]:~#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.

    [email protected]:~# gedit /etc/profile

    At the bottom you just copy and paste below lines.

    unset _JAVA_OPTIONS
    export JAVA_HOME
    export JRE_HOME
    export PATH
    Else, if only JDK installation Require
    unset _JAVA_OPTIONS
    export JAVA_HOME
    export JRE_HOME
    export PATH

    Now just save and close page:

    6. After this perform some commands in terminal.

    [email protected]:~# update-alternatives --install "/usr/bin/java" "java" /usr/local/java/jre1.8.0_112/bin/java" 1
    [email protected]:~# update-alternatives --install "/usr/bin/javac" "javac" /usr/local/java/jdk1.8.0_112/bin/javac" 1
    [email protected]:~# update-alternatives --install "/usr/bin/javaws" "javaws" /usr/local/java/jre1.8.0_112/bin/javaws" 1
    [email protected]:~# update-alternatives --set java /usr/local/java/jre1.8.0_112/bin/java
    [email protected]:~# update-alternatives --set javac /usr/local/java/jdk1.8.0_112/bin/javac
    [email protected]:~# update-alternatives --set javaws /usr/local/java/jre1.8.0_112/bin/javaws
    [email protected]:~# . /etc/profile
    [email protected]:~#

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

    [email protected]:~# echo $HOME

    [email protected]:~# echo $PATH

    [email protected]:~# echo $JAVA_HOME
    [email protected]:~# echo $JRE_HOME
    [email protected]:~# 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)


  8. Arpit Semwal says:

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

    • Ravi Saive says:


      Seems your Java installation was not successful, try to follow the instructions again carefully..

    • aymanezizi says:

      yes because he wrote export command in wrong way, you should write it as :
      export PATH=/opt/java/jdk1.8.0_45/bin:/opt/java/jdk1.8.0_45/jre/bin

      then you will notice that the new version installed

  9. lothmas says:

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

  10. 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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.