This article applies to:
- Platform(s): Xubuntu Linux
- Java version: 22.0.2
Download
- Go to https://jdk.java.net and download the JDK version you want. For now, I choose JDK 22, and pick the download link for Linux/64 build, tar.gz format of JDK 22.0.2 General-Availability Release. So my downloaded file is
openjdk-22.0.2_linux-x64_bin.tar.gz
. - Check the download file size and sha256 hash string to make sure that you have downloaded the full, uncorrupted file. For example, the jdk.java.net site reports that the Linux/x64 build file is
201996264
bytes, and the SHA256 hash string is41536f115668308ecf4eba92aaf6acaeb0936225828b741efd83b6173ba82963
xubuntu:~/share/download/java$ ls -l total 197264 -rwxrwxrwx 1 root root 201996264 Aug 26 14:45 openjdk-22.0.2_linux-x64_bin.tar.gz xubuntu:~/share/download/java$ sha256sum openjdk-22.0.2_linux-x64_bin.tar.gz 41536f115668308ecf4eba92aaf6acaeb0936225828b741efd83b6173ba82963 openjdk-22.0.2_linux-x64_bin.tar.gz
Install
- I like to extract the JDK content to a temporary folder before moving/copying it to the default folder of
/usr/lib/jvm
.xubuntu:~/share/download/java$ mkdir ~/temp/jdk xubuntu:~/share/download/java$ tar -xvzf openjdk-22.0.2_linux-x64_bin.tar.gz -C ~/temp/jdk jdk-22.0.2/bin/jar jdk-22.0.2/bin/jarsigner jdk-22.0.2/bin/java jdk-22.0.2/bin/javac ... omitted-output ... jdk-22.0.2/lib/src.zip jdk-22.0.2/lib/tzdb.dat jdk-22.0.2/release xubuntu:~/share/download/java$ cd ~/temp/jdk xubuntu:~/temp/jdk$ ls -l total 4 drwxrwxr-x 8 h0ward h0ward 4096 Aug 26 15:18 jdk-22.0.2
- Move the new JDK content to
/usr/lib/jvm
xubuntu:~/temp/jdk$ sudo mkdir /usr/lib/jvm xubuntu:~/temp/jdk$ sudo mv jdk-22.0.2/ /usr/lib/jvm xubuntu:~/temp/jdk$ ls -l /usr/lib/jvm total 4 drwxrwxr-x 8 h0ward h0ward 4096 Aug 26 15:18 jdk-22.0.2
Configure
- Update environment variables to point to the newly installed JDK by editing the
/etc/environment
file.xubuntu:~/temp/jdk$ sudo nano /etc/environment
- Add
JAVA_HOME
variable, and JDKbin
toPATH
.JAVA_HOME="/usr/lib/jvm/jdk-22.0.2" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/lib/jvm/jdk-22.0.2/bin"