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

Wayan Saryada

Founder at Kode Java Org
I am a programmer, a runner, a recreational diver, currently live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. You can support my works by donating here. Thank you 🥳

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.