Home Java Java-get-example Get Java Version
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Get Java Version

Advertisement
The Java has a lot changes since JDK1.0 as well as numerous additions of classes and packages. In addition to this class and package ,Java introduced class standard libraries. The classes, packages and various Standard libraries is Java Version

Get Java Version

     

The Java has a lot changes since JDK1.0 as well as numerous additions of classes and packages. In addition to this class and package ,Java introduced class standard libraries. The classes, packages and various Standard libraries  is Java Version

Understand with Example

In this Tutorial we want to describe you a code that help you in understanding in get Java Version. For this we have a class name Get Java Version. Inside the main method we declared a string array variable name 'pro' is initialized with respective value.

1)System.getproperties  - This  method returns a string containing property value . Incase the property does not exist, this version of getProperty() returns null.

for loop is used to display the name of Java version present in String pro using System.out.println.

2)properties.getproperties(pro[i])-This method return you the value of java version by passing pro string in it and print it using println.

On execution of code, the code show you Java Version and its value present in a String array variable.

GetJavaVersion.java


import java.util.*;

public class GetJavaVersion {

  public static void main(String args[]) {

  String[] pro = {
  "java.version""java.vm.version""java.runtime.version"
  };

  Properties properties = System.getProperties();
  for (int i = 0; i < pro.length; i++) {
  System.out.print(pro[i]+"\t\t: ");
  System.out.println(properties.getProperty(pro[i]));
  }
  }
}

Output
java.version  : 1.6.0_01
java.vm.version   : 1.6.0_01-b06
java.runtime.version  : 1.6.0_01-b06
 

Download code

Advertisements

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 5, 2008

Ask Questions?    Discuss: Get Java Version   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com