Possible Duplicate:
Using Java 7 SDK features in Java 6
I have a Java application (actually it is a Scala application, but I don't think that this changes much), running on JVM 6.
I would like to use some of the new Java 7 APIs like NIO2 if they are available, but fallback to other implementation if they are not available. The goal is to make use of Java 7 APIs if possible while keeping compatibility with Java 6 with the same binaries (jar).
It should be possible by checking with Class.forName("java.nio.file.attribute.BasicFileAttributeView")
, but I don't know how if e.g. the java class files have a different version, which would make it impossible to use Java 7 classes in code that is also runnable in Java 6.