How to check java version in kubernetes pod

To check the Java version in a Kubernetes pod, you can SSH into the pod and run the following command:

kubectl exec -it <pod-name> -- java -version

Here, replace <pod-name> with the actual name of the pod you want to check.

This command executes the java -version command inside the given pod and shows the Java version installed in that pod.

For example, if you have a pod named “my-pod” in the “my-namespace” namespace, the command would be:

kubectl exec -it my-pod -n my-namespace -- java -version

After running the command, you will see the Java version output, something like:

openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment Zulu11.45+27-CA (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.45+27-CA (build 11.0.10+9-LTS, mixed mode)

This output indicates that the pod has Java version 11.0.10 installed.

Leave a comment