ubuntu install java 8 jdk code example

Example 1: java 8 install ubuntu

sudo apt-get install openjdk-8-jdk

Example 2: debian install java

# If you want java 11:
sudo apt install -y default-jre

# If you want java 8:
sudo apt update
sudo apt install -y apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt update
sudo apt install -y adoptopenjdk-8-hotspot

# Switch java version
sudo update-alternatives --config java

Example 3: instalar java ubuntu 18.04

sudo apt install default-jre

Example 4: instalar java ubuntu 18.04

OutputCommand 'java' not found, but can be installed with:

apt install default-jre            
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless