title: Can a Java Factory class be structured to instantiate either Java 6 or Java 7 specific class based on JVM version?
body: <p>Java 7 can run Java 6 code, but Java 6 can't run Java 7-specific code (e.g. NIO 2.0).  I want to support users using either JVM, but give Java 7 users additional functionality.</p>
  
  <p>Is it possible to build a Factory class with Java 6 using an interface such that it can conditionally instantiate a Java 6 compiled class if the JVM is 1.6 or a Java 7 compiled class if the JVM is Java 7?</p>
  
  <p>E.g. something like:</p>
  
  <pre><code>String javaVersion = System.getProperty("java.version");
  if (javaVersion.startsWith("1.6")) {
      myInterface = Class.forName("com.project.java6.MyInterfaceImplementation").newInstance();
  } 
  else {
      myInterface = Class.forName("com.project.java7.MyInterfaceImplementation").newInstance();
  }
  </code></pre>
  
  <p>If so, would the two versions need to be packaged in separate jars, one for the Java 6 compiled code and the other for the Java 7 code?</p>