apt install openjdk 8 9 11 17

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update

sudo apt-get install openjdk-8-jdk -y

sudo update-alternatives --config java
sudo update-alternatives --config javac

java -version and javac -version
DreamCoder