Obviously, if you compile and run your code on Java 6 you cannot use classes that have been added to Java's standard library in Java 7, because those will not be present on Java 6.
For the rest, there is no practical difference at all. Almost all optimization is done during runtime by the JVM and the JIT; the Java compiler does almost no optimization.