Search code examples
javacompilationjvmbytecodebackwards-compatibility

JRE version must be equal to or above JDK version?


I've read that the bytecodes that the JDK generate are generic. What I say is that they only do things like memory mapping, calling, etc... So if that's true, it would mean that I can, for example, if write a program with characteristics of JDK 1.7, I don't need to worry about if it can run in a user with JRE 1.6? (It's an example, it could happen with more exagerated cases).

So, my question is: Can I write a program with new things from 1.7 and run it in 1.6?


Solution

  • Can I write a program with new things from 1.7 and run it in 1.6?

    No. Java is not backward compatible.

    Note that it is possible to create code compatible with a Java 1.6 JRE in a 1.7 JDK by using the cross-compilation options, but that code can only use the classes, attributes, methods and language features available in version 1.6.