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

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

Get 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