Install JDK

  • Download JDK

    1. Visit to Oracle Java SE download page.
    2. Download JDK for Linux 64 such as jdk-8u91-linux-x64.tar.gz.
  • Check if we have Java installed on our system

    1. Open the Terminal
    2. Type java -version.

    If we have OpenJDK installed:

    java version "1.7.0_15"
    OpenJDK Runtime Environment (IcedTea6 1.10pre) (7b15~pre1-0lucid1)
    OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
    
  • Copy .gz to destination folder

    1. cd /home/"our_user_name"/Downloadssuch ascd /home/yen/Downloads.
    2. sudo cp -r jdk-8u91-linux-x64.tar.gz /usr/local/java
  • Unpack the .gz

    1. cd /usr/local/java
    2. sudo tar xvzf jdk-8u91-linux-x64.tar.gz
  • Edit the system PATH file

    1. sudo gedit /etc/profile
    2. Scroll down to the end of the file.
    3. add the following lines below:
      JAVA_HOME=/usr/local/java/jdk1.8.0_91
      JRE_HOME=$JAVA_HOME/jre
      PATH=$PATH:$JRE_HOME/bin:$JAVA_HOME/bin
      export JAVA_HOME
      export JRE_HOME
      export PATH
      
  • Inform system where the Oracle Java JDK/JRE is

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_91/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_91/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_91/bin/javaws" 1
    
  • Set it to be default

    sudo update-alternatives --set java /usr/local/java/jdk1.8.0_91/bin/java
     sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_91/bin/javac
     sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_91/bin/javaws
    
  • Reload system wide PATH /etc/profile

    source /etc/profile

  • Double check

    1. java -version
      java version "1.8.0_91"
      Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
      
    2. javac -version

      javac 1.8.0_91

    3. We can write a simple java class to test.
  • Restart Ubuntu

Install JDK in Ubuntu

results matching ""

    No results matching ""