Home Java Java-get-example Java get Version

Related Tutorials


 
 

Share on Google+Share on Google+

Java get Version

Advertisement
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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 1, 2008

Related Tutorials

Discuss: Java get Version   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
3qn
March 19, 2013
mistake

In second line shoud be "java.version" not "os.version"
DMCA.com