Download an appropriate JDK for your operating system. The latest JDK can be downloaded from the official OpenJDK website.
Once installed, you can use the java command from your command line.
Check if the correct java version is installed. The following shows the output for OpenJDK 21:
$ java -version
openjdk version "24" yyyy-mm-dd
OpenJDK Runtime Environment (build 24+XX-XX)
OpenJDK 64-Bit Server VM (build 24+XX-XX, mixed mode, sharing)
You need to set the JAVA_HOME environment variable to the JDK installation directory. You can follow this guide to set JAVA_HOME for your platform.