java install ubuntu code example

Example 1: install openjdk 8 sdk on 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: ubuntu install python

# first do:
sudo apt-get update
# after do:
sudo apt-get install python3.6
# then it should be installed

Example 4: install java ubuntu

sudo apt install default-jdk

Example 5: install java ubuntu

sudo apt install default-jre # installs java
sudo apt install default-jdk # installs javac

Example 6: install java ubuntu

sudo apt install default-jre