How to install the JDK on Ubuntu
OpenJDK is in the Ubuntu repositories. List what is available:
apt search openjdk | grep jdk
Install one version (replace 21 with a version you see listed):
sudo apt update sudo apt install openjdk-21-jdk
Check:
java -version javac -version
If several versions are installed, choose with:
sudo update-alternatives --config java