How to check whether the current version of Java is higher than 1.6
<p>I would like to support Java 1.5+ in my application, but selectively enable features if the user is running on a Java 1.6+ JVM, using Java 1.6+-specific API calls. So I need a way to check the current version of the JVM and ensure that only available APIs are used. Of course, I'll be compiling with <code>-target 1.5</code>.</p>

<p>I've come up with:</p>

<pre><code>if (System.getProperty("java.vm.version").startsWith("1.5")) {
    // Do 1.5 things
} else {
    // Do 1.6+ things
}
</code></pre>

<p>It seems to fit the bill, but I'm wondering if there's a "better" way?</p>

<p>Furthermore, if I'm careful not to call any 1.6 API calls from my 1.5 code, is there still a possibility that I will get <code>NoSuchMethodError</code>s, <code>NoClassDefFound</code>s when running on a 1.5 JVM?</p>
