... and if you are on a server that has SAS software installed but not SAS Foundation you can also use the java -version command. The path will vary depending on where SAS software has been installed but on my server I can check it like so:
[sas@sas94m8 ~]$ /opt/sas94m8/sashome/SASPrivateJavaRuntimeEnvironment/9.4/jre/bin/java -version
openjdk version "11.0.15" 2022-04-19 LTS
OpenJDK Runtime Environment Zulu11.56+20-SA (build 11.0.15+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.56+20-SA (build 11.0.15+10-LTS, mixed mode)