-
Download the x64 Debian package from Oracle https://www.oracle.com/java/technologies/downloads/
-
Install the .deb package.
sudo apt install ~/Downloads/jdk-20_linux-x64_bin.deb
- Set JDK 20 as defaults:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-20/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-20/bin/javac 1
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-20/bin/jar 1
- Set JDK as defaults (continued):
When you run these commands, a select dialog comes up, enter the number that corresponds to the JDK 20 file path.
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar
- All done!
Verify which version of Java is installed with this command:
java -version
If all is correct, it should be JDK 20 :)