This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is there any neat way to check that the version of Java Runtime Environment that you're running on is good enough for the program?
My idea is that I'd be able to build into the program somewhere the concept that it should run on, say, 1.6.0u1 or better, and the program should check whether it is running on such a JRE.
Of course, I know that System property "java.version" gives you the Java version. That makes it easy to test if you are running on a particular exact version of JRE. But what I am looking for is any API that can tell whether version X is as good or better than version Y. [ October 17, 2007: Message edited by: Peter Chase ]
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I saw something once that used reflection to test for classes and methods that appeared in major and minor JVM releases. It started from 1.x and worked up until something was not found. Is that the kind of thing you're thinking of?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Oct 30, 2001
Well, I wasn't really wanting to get involved with how it worked. I hoped there was an API for it.
The thing that made me think there might be was the Apple API for choosing your Java, where you specify the version as something like "1.5.0+", meaning 1.5.0 or better.
Conveniently, though, I think I already have an implicit version check. My applications are launched via my own program, which uses JNI Invocation Interface. In this, you specify the JNI version you expect. Java 6 has a different JNI version to older Javas and I ask for the Java 6 version, so if I accidentally tried to start my program with a Java 5 or older, it wouldn't launch.
I thought a jvm would not run a jar file that was compiled on a version later than the jvm, I just was told recently that this is the case.
"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Joined: Oct 30, 2001
That's somewhat true. In my case, the Windows stuff is compiled with -source 1.5 and -target 1.5, so it will run on a Mac with Java 5 (the Mac Java 6 is only just coming out now). But I want to make sure that, when it runs on Windows, it uses Java 6, for the improved performance and some important bug-fixes. [ October 18, 2007: Message edited by: Peter Chase ]
Joined: Jan 29, 2003
Veering off topic perhaps ... I just watched an OSGi introductory video on InfoQ. An application "bundle" can contain multiple versions of jars, JNI modules, etc and declare which ones should be used based on JVM and OS. Pretty cool.