1sudo apt install default-jre # installs java
2sudo apt install default-jdk # installs javac
1// for debian & debian based linux distributions
2 sudo su or su -
3 echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu focal main" | tee /etc/apt/sources.list.d/linuxuprising-java.list
4 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A
5 apt-get update
6 Ctrl + D or exit
7// for Ubuntu, Linux Mint, Pop!_OS or Zorin Os
8 sudo add-apt-repository ppa:linuxuprising/java
9 sudo apt update
10
11// Now you can install Oracle JDK 16 on Debian / Ubuntu and Linux distributions based on these:
12 //Install and make Oracle JDK 16 the default JDK version:
13 sudo apt install oracle-java16-installer --install-recommends
14 //Install but don't make Oracle JDK 16 the default JDK version:
15 sudo apt install oracle-java16-installer --no-install-recommends
16
17//To check which Java version is set as default on your system
18 java -version or javac -version
19
20//To accept the Oracle Java 16 license automatically
21 echo oracle-java16-installer shared/accepted-oracle-license-v1-2 select true | sudo /usr/bin/debconf-set-selections
22 //If that doesn't work, also try this command:
23 echo oracle-java16-installer shared/accepted-oracle-licence-v1-2 boolean true | sudo /usr/bin/debconf-set-selections
1#Install java in Linux
2sudo apt install openjdk-11-jre-headless -y # version 11.0.10+9-0ubuntu1~20.04, or
3sudo apt install default-jre -y # version 2:1.11-72
4sudo apt install openjdk-8-jre-headless -y # version 8u282-b08-0ubuntu1~20.04
5sudo apt install openjdk-13-jre-headless -y # version 13.0.4+8-1~20.04
6sudo apt install openjdk-14-jre-headless -y # version 14.0.2+12-1~20.04