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.
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:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java get Version View All Comments
Post your Comment