Install OpenJDK 17 LTS on Ubuntu 24.04|22.04|20.04|18.04
- Download OpenJDK 17. To install OpenJDK 17, visit OpenJDK 17 release page and get the latest version available for your CPU architecture,
1
wget https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz
- Extract downloaded archive.
1
tar xvf openjdk-17.0.2_linux-x64_bin.tar.gz
- Move the folder created after extraction.
1
sudo mv jdk-17.0.2/ /usr/local/
- Set environment variables inside
/etc/profile.d/
directory.1
2
3$ sudo vi /etc/profile.d/jdk17.sh
export JAVA_HOME=/usr/local/jdk-17.0.2
export PATH=$PATH:$JAVA_HOME/bin - Source the files to make variables available in your current shell session.
1
source /etc/profile.d/jdk17.sh
- Confirm Java version using the following command.
1
2
3
4$ java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.