Main Content

Which Version of Java am I running?

Archive - Originally posted on "The Horse's Mouth" - 2009-04-02 16:52:18 - Graham Ellis

Write a test program to use the getProperty method on System:

public class Sample {
  public static void main (String [] args) {
  System.out.println("*** Hello Melksham ***");
  System.out.println(System.getProperty("java.vm.vendor").toString());
  System.out.println(System.getProperty("java.version").toString());
  }
}


Compile it

[trainee@easterton a9tom]$ javac Sample.java

and run it!

[trainee@easterton a9tom]$ java Sample
*** Hello Melksham ***
Sun Microsystems Inc.
1.6.0_10-beta
[trainee@easterton a9tom]$


It is VITAL (did I shout vital loudly enough for you?) to have the correct version of Java in use when you run your Tomcat!. Today's course ... I am using Sun's Java 6 (a.k.a. 1.6) which will work with Apache Tomcat up to version 6. Don't assume that Tomcat and Java version numbers always match up nicely in this way - they don't