Java get Version
In this section, you will learn how to obtain the java version and the OS version. We are providing you an example which will obtain the java version installed on the system and the OS version by using the System.getProperty(). This will provide all the properties of the system.
System.getProperty("java.version")- This will return the java version installed on the system.
System.getProperty("os.version")- This will return the OS version.
Understand with Example
In this example we want to describe you a program code that helps you to get the java version and the OS version. For this we have a class name 'GetVersion',Inside the main method a string variable name OSversion and JAVA version that is used to store the java version installed on the system and the OS version by using the System.getProperty ( ) method. The System.out.println is used to display the version of OS and java obtained by the get Property( ) stored in a OSversion and JAVAversion.On execution of the given below code, the command prompt display the version of OS and java.
Here is the code of GetVersion.java
class GetVersion
|
Output will be displayed as: