Get Java Version

Tags: System

In this Java core tutorial, we learn how to get the Java version in a Java program.

How to use System.getProperty() static method to get Java version

GetJavaVersion.java

public class GetJavaVersion {
    public static void main(String[] args) {
        String jdkVersion = System.getProperty("java.version");

        System.out.println("Java version: " + jdkVersion);
    }
}
The output is:
Java version: 14.0.1

Happy Coding 😊

Get Operating System Name in Java

Get User Home Directory in Java