Installing OpenJDK 21 on DietPI

Open an ssh session as root to the DietPI machine.
Type the following commands:

  1. cd /tmp
  2. wget https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz
  3. tar -xvf openjdk-21.0.2_linux-x64_bin.tar.gz
  4. mv jdk-21.0.2/ /opt/jdk-21
  5. echo 'export JAVA_HOME=/opt/jdk-21' >> /etc/bash.bashrc
    echo 'export PATH=$JAVA_HOME/bin:$PATH' >> etc/bash.bashrc
  6. exit

open the ssh session again and check if java is available:
java --version

This should output something like
openjdk 21.0.2 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-58)
OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

Above instructions are for the current jdk version (21.0.2) on an x64 machine (Microsoft Hyper-V VM). Change the url and filename at items 2 and 3 for other versions. (See https://jdk.java.net/ )