How do I get Java Runtime Environment (JRE) version?

This code snippet show you how to get Java / JRE version by reading the java.version from the system properties. We use the System.getProperty(String key) method to get the value of the property and it will be returned as a string value.

package org.kodejava.example.lang;

public class JavaVersion {
    public static void main(String[] args) {
        // You can get the version of Java Runtime Environment
        // running on your machine by reading the "java.version"
        // property value from the system.
        String version = System.getProperty("java.version");

        // Just show to the world your JRE version :)
        System.out.println("Java Version = " + version);
    }
}

In my computer it print the following output:

Java Version = 1.8.0_121