How to Verify Java Version
Java is the Programming Language and computing platform that was released by Sun Microsystems in 1995. Java Language has two main components: JDK (Java Development Kit) and JRE (Java Runtime Environment). The Java Development Kit (JDK) is an environment used for developing the Java application.
Java Development Kit also includes Java Runtime Environment (JRE), a Java compiler (javac), an interpreter/loader (Java), an archiver (jar), and other developing tools. In this Java Tutorial, we will learn how to verify java version.
What is Java Version?
Java Runtime Environment consists of core classes and Supporting Files to run any program in Java. JRE also consists of Java Virtual Machine (JVM). There are many versions of JRE.
Some applications require different versions due to compatibility problems. The first number in the Java version indicates the major version, and the second number represents the release. In this article, we will learn how to verify or check the version of Java that you are using.
How to Verify Java Version?
There are three procedures to check the version of Java. They are:
1. Using Command Prompt
2. Using Control Panel
3. Using Java System Class
There are various Java Versions for executing some applications. We have to check the version of Java. Some applications are compatible in a particular Java.
1. Using Command Prompt
To check the Java version using Command Prompt, follow the below steps:
1: Press Windows Button and Type Command Prompt
2: Then Open Command Prompt
3: Then type the following Command
java -version
2. Using Control Panel
To check Java version using Control Panel, follow the following steps:
1: Press Windows button then type Control Panel
2: Open the Control Panel
3: Open Java and then click on the about
3. Using Java System Class
We can also use the System class of Java to verify the Java version. There is a getProperty() method in the System class. The getProperty() method accepts a String key as an argument. A key represents the name of the system property.
The signature of the getProperty() method is:
public static String getProperty(String key)
This method returns the String value of the system property. It returns null if there is no property with that specified key. This method can throw a NullPointerException if the key is null and an IllegalArgumentException if the key is empty.
Example to verify Java version using the System class:
package com.techvidvan.verifyjavaversion; public class JavaVersionExample { public static void main(String args[]) { //determines JRE version System.out.println("Java Version is: " + System.getProperty("java.version")); } }
Output
Conclusion
In this article, we learned to check or verify the version of Java we are using. We can do it in the three ways that we discussed with the steps and examples. You can now easily verify the version of Java if you don’t remember it.