Skip to content

Instantly share code, notes, and snippets.

@woodRock
Created May 27, 2023 06:13
Show Gist options
  • Save woodRock/05616fbc7b7273a921e08f42a0d7133a to your computer and use it in GitHub Desktop.
Save woodRock/05616fbc7b7273a921e08f42a0d7133a to your computer and use it in GitHub Desktop.
Install JDK 20 in Ubuntu:

How to install JDK 20 on Ubuntu

  1. Download the x64 Debian package from Oracle https://www.oracle.com/java/technologies/downloads/

  2. Install the .deb package.

sudo apt install ~/Downloads/jdk-20_linux-x64_bin.deb
  1. 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
  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
  1. All done!

Verify which version of Java is installed with this command:

java -version

If all is correct, it should be JDK 20 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment