checking JVM version conveniently

Hello fellows,

I'd like to check the Java Version during the start of my program. So that I could say: "Oh Oh, you need to have the Java Version higher or equal to 1.5.0_06" and aborting the program.

If the user runs it with 1.5.0_03 for example.. it could be, that there are some bugs in it and my program crashes... this should be avoided!

I could get the java version, but then I have to check it in a cumbersome way, like.. get the string, format it well... casting to float, check major version, checking minor version...

so I'm searching now a convinient way for this, because actually everybody, who ships a program, should check this... so there must be a convinient java way... but I didnt found anything!

Do you have a suggestion?

Thanks.

[793 byte] By [SpecialAgenta] at [2007-10-3 10:30:52]
# 1

You check the java version with this instruction:

String myversion = System.getProperty("java.vm.version"));

Exist more properties and you can see all with this source:

Enumeration<Object> e = System.getProperties().keys();

while (e.hasMoreElements()) {

String skey = (String)e.nextElement();

System.out.println(skey + " -> " + System.getProperty(skey));

}

And if posible check the java version with a .bat(Windows) or .sh(Unix) executing the command: java -version

danjaredga at 2007-7-15 5:53:36 > top of Java-index,Desktop,Runtime Environment...