How to run Java in compatibility mode?

橙三吉。 提交于 2019-12-10 19:27:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!