Linux – Installation of Oracle Jave JDK/JRE

  1.  check OS architecture: 32-bit or 64-bit?

    file /lib/systemd/systemd

  2. check if we have Java installed on our OS

    java -version

    if we should uninstall OpenJDK if we have one installed on our OS.

    sudo apt-get purge openjdk-\*

  3. create a directory to hold our Oracle Java JDK binaries.

    sudo mkdir -p /usr/local/oracle-java

  4. Download Oracle Java JDK for linux
    link:http://www.oracle.com/technetwork/java/javase/downloads/index.html
  5. copy the file we download to the directory we create

    sudo cp -r jdk-8u20-linux-i586.tar.gz /usr/local/oracle-java/
    cd /usr/local/oracle-java/

  6. unpack the compressed file we download

    sudo tar xvzf jdk-8u91-linux-x64.tar.gz

  7. Edit the system PATH file /etc/profile and add the following system variables to your system path.

    sudo vim /etc/profile

    then add the following lines below to the end of the file profile (finally save and exit):

    JAVA_HOME=/usr/local/oracle-java/jdk1.8.0_91
    PATH=$PATH:$JAVA_HOME/bin
    export JAVA_HOME
    export PATH

  8. Inform our OS where our Oracle Java JDK is located.

    sudo update-alternatives –install “/usr/bin/java” “java” “/usr/local/oracle-java/jdk1.8.0_91/bin/java” 1
    sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/local/oracle-java/jdk1.8.0_91/bin/javac” 1
    sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/local/oracle-java/jdk1.8.0_91/bin/javaws” 1

  9. Inform our OS that Oracle Java JDK must be the default Java.

    sudo update-alternatives –set java /usr/local/oracle-java/jdk1.8.0_91/bin/java
    sudo update-alternatives –set javac /usr/local/oracle-java/jdk1.8.0_91/bin/javac
    sudo update-alternatives –set javaws /usr/local/oracle-java/jdk1.8.0_91/bin/javaws

  10. Reload our system wide PATH /etc/profile

    source /etc/profile

  11. test if we hava Java installed

    java -version
    javac -version

  12. Successfully!

Leave a Reply

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