1sudo apt update
2sudo apt install openjdk-11-jdk
3
4sudo apt update
5sudo apt install openjdk-8-jdk
1# Java in ubuntu
2# first check if java is already installed or not using
3java -version
4
5# install openjdk (Java Development Kit)
6sudo apt install default-jdk
7# it will ask for confirmation...around 480 MB will be downloaded
8# this will install both the latest jdk and jre of openjdk distribution
9
10# check for java
11java -version
12
13#check for javac
14javac -version
15
16# If you only want to install jre and not jdk, just run
17sudo apt install default-jre