Installing JDK on ubuntu 18.04

Installing JDK on ubuntu 18.04

JDK Installation

  1. Download jdk for linux from oracle official site or from here.
  2. Create folder inside /opt for java-jdk installation
    sudo mkdir /opt/java-jdk 
  3. Since JDK downloaded is compresses so uncompress(untar) JDK file to /opt/java-jdk    
    sudo tar -C /opt/java-jdk -zxf /home/lenovo/Downloads/jdk-13.0.2_linux-x64_bin.tar.gz
  4. Install java in  usr/bin/java with priority 1 
    sudo update-alternatives  --install /usr/bin/java java /opt/java-jdk/jdk-13.0.2/bin/java 1
  5. Install javac in usr/bin/javac with priority 1
    sudo update-alternatives  --install /usr/bin/javac javac /opt/java-jdk/jdk-13.0.2/bin/javac 1

Setup path for JDK

  1. Open terminal –>ctrl+alt+t 
    lenovo@jags:~$ sudo gedit  /etc/profile
    • opens “profile” file to add java_home directory 
  2. Add following codes to “profile” file
export JAVA_HOME 
export JRE_HOME
export PATH
Share this on facebook

Subscribe to our Youtube Channel

Leave a comment

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