问题
Does Java support running in compatibility mode? In other words if we have JDK 8 install on system, can it be configured to run my application on 7 or previous release using the same installation ?
I can give one example like IE-11 can be switch to run as IE 8, 9, or 10 based on the compatibility option.
回答1:
I agree with the comment of Kayaman. There are 2 types of incompatibilities that could occur: bytecode changes (some feature supported in 8 and not in 7 - new Java versions tend to be upward compatible - so 8 will be able to run all 7-targeted code) and library changes which is more problematic.
If you have compiled with Java 8 targeting 7+, your bytecode will be compatible with Java 7 JVM, but you have no guarantee that it will run with Java 7 libraries.
Your best bet is then to compile and run with Java 7 - and it will (most probably) run with Java 8.
Then there are other changes that may impact your application (GC performance for instance).
来源:https://stackoverflow.com/questions/37020344/how-to-run-java-in-compatibility-mode