Home Java Java-get-example Java get Version



Java get Version
Posted on: November 1, 2008 at 12:00 AM
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().

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
{
  public static void main(String[] args) 
  {
  String OSversion = System.getProperty("os.version");
  String JAVAversion = System.getProperty("os.version");

  System.out.println("The version of OS is: "+OSversion);
  System.out.println("The version of JAVA is: "+JAVAversion);
  }
}

Output will be displayed as:

Download Source Code

Related Tags for Java get Version:
javacidepropertiesiopropertygetversioninstallsystemviusingthisidaiieexampletolearnexameareilrsisectionpeinstamososjesemallhowprosystiexawhichxampsisllmplpropereaandarstalledrtropevassthavstpleplpropprndono


More Tutorials from this section

Ask Questions?    Discuss: Java get Version   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.