Rob Spoor wrote:
Jesper de Jong wrote:But code compiled with a newer version will not work on an older version.
Unless you tell the compiler to make the generated byte code compatible with an older version (-source and -target compiler flags).
Additionally, your code needs to not depend on any newer library methods or classes. If a method was added in JDK 7, it won't be available using the older library, and your code will fail when it tries to call that method. This can be a little harder to check for - I find if I really need something to run on JDK 6, it's best to compile and
test using JDK 6, not relying on the -source and -target options. But it is
possible to get it to work using the -source and -target, if you need to. It's just risky.