如何在兼容模式下运行Java? [英] How to run Java in compatibility mode?

查看:215
本文介绍了如何在兼容模式下运行Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java是否支持在兼容模式下运行?换句话说,如果我们在系统上安装了JDK 8,是否可以将其配置为使用相同的安装在7或以前的版本上运行我的应用程序?

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 ?

我可以给出一个像IE-11这样的例子可以根据兼容性选项切换到IE 8,9或10。

I can give one example like IE-11 can be switch to run as IE 8, 9, or 10 based on the compatibility option.

推荐答案

我同意Kayaman的评论。
有两种类型的不兼容性可能发生:字节码更改(8中支持某些功能而7中不支持 - 新Java版本往往向上兼容 - 因此8将能够运行所有7个目标代码)和库更改哪个更有问题。

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.

如果您使用Java 8编译7+,您的字节码将与Java 7 JVM兼容,但您无法保证它将使用Java 7库运行。

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.

然后最好用Java 7编译和运行它 - 它最有可能用Java 8运行。

Your best bet is then to compile and run with Java 7 - and it will (most probably) run with Java 8.

然后还有其他可能影响您的应用程序的更改(例如GC性能)。

Then there are other changes that may impact your application (GC performance for instance).

这篇关于如何在兼容模式下运行Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆