Search code examples
javaversioncompatibility

Java(JRE) version compatibility for compiled code


When I programme I don't take care if I'm using the features in Java 7 or Java 5. But as far as I think if I use only Java 5 features my complied byte codes should be run also on a JRE version 5. But how can I check if my compiled code will be compatible with JRE v. 5 or even earlier or no.

I'm interested to know the answer of this question more generally for Web and Enterprise applications.


Solution

  • You can compile your code with a specific version using the -target option

    Try compiling with different targets to see which compiles and which doesn't

    http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html