how to install jdk on ubuntu 20.04 code example

Example 1: install jdk linux

sudo apt install openjdk-8-jdk

Example 2: install java in ubuntu 20.04

# Java in ubuntu
# first check if java is already installed or not using 
java -version

# install openjdk (Java Development Kit)
sudo apt install default-jdk
# it will ask for confirmation...around 480 MB will be downloaded
# this will install both the latest jdk and jre of openjdk distribution

# check for java
java -version

#check for javac
javac -version

# If you only want to install jre and not jdk, just run
sudo apt install default-jre

Example 3: ubuntu install jdk 14

sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java14-installer oracle-java14-set-default

Example 4: install java on ubuntu 20.04

sudo apt install default-jre

Tags:

Java Example