java linux install code example

Example 1: installing java on linux

# install default JDK
sudo apt install default-jdk
# install default JRE
sudo apt install default-jre
# install specific JDK version
sudo apt install openjdk-17-jdk
# install specific JRE version
sudo apt install openjdk-17-jre

Example 2: install jdk linux

sudo apt install openjdk-8-jdk

Example 3: install java ubuntu

sudo apt install default-jdk

Example 4: install java ubuntu

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