How to install Java in Ubuntu / Linux

Process to install Java in Ubuntu or any Linux based Systems:

  1. Open Terminal from Application Dash or press Ctrl+Alt+T

  2. Update repository:

    sudo add-apt-repository ppa:openjdk-r/ppasudo apt-get update
  3. Run the following command in the Terminal:

    sudo apt-get install openjdk-8-jdksudo apt-get install openjdk-8-source #this is optional, the jdk source code
  4. Type command line as below…

    apt-cache search jdk

    (Note: openjdk-8-jdk is symbolically represented here. You can choose the JDK version according to your requirements)

  5. For “JAVA_HOME” (Environment Variable) type command as shown below, in “Terminal” using your installation path…

    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk

    (Note: “/ usr / lib / jvm / java-8-openjdk” is for demonstration purposes only and you should use your path based on your installation.)

  6. For “PATH” (Environment Variable) type command as shown below, in “Terminal” using your installation path…

    export PATH=$PATH:/usr/lib/jvm/java-8-openjdk/bin

    (Note: “/ usr / lib / jvm / java-8-openjdk” is for demonstration purposes only and you should use your path based on your installation.)

  7. Check for “open jdk” installation, just type command in “Terminal” as shown below

    javac -version