JRE 1.4是否支持使用Java 1.5和Linux编译的类。 1.6? [英] Will JRE 1.4 support classes compiled with Java 1.5 & 1.6?

查看:253
本文介绍了JRE 1.4是否支持使用Java 1.5和Linux编译的类。 1.6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用1.5和1.6编译的代码是否会在1.4 JRE上运行?我们不确定1.4 JRE支持哪些Java版本。

Will code compiled using 1.5 and 1.6 run on a 1.4 JRE? We weren't sure which Java versions the 1.4 JRE supports.

我们知道如果有问题的代码实现了1.5或1.6支持的功能,那么肯定是不编译 ...并且有一些风险带有向后编译但不确定1.4 JRE是否会拒绝加载1.5 / 1.6编译课程与否。

We know that if the code in question implements 1.5 or 1.6 supported features then it definitely won't compile... and that there are some risks with "backwards compiling" but wasn't sure if the 1.4 JRE would refuse to even load the 1.5/1.6 compiled classes or not.

更新:我确认你得到了一个 java.lang。如果在JRE 1.4上运行1.6类文件,则UnsupportedClassVersionError 异常。

Update: I confirmed you get a java.lang.UnsupportedClassVersionError exception if you run an 1.6 class file on JRE 1.4.

推荐答案

如果您只是使用 javac 1.6的默认值,您的类文件将无法在旧版本的Java上运行。

If you just build with the defaults of javac 1.6, your class files will not work on old versions of Java.

最佳方式编译旧Java只是为了使用较旧的JDK版本。但如果你真的想尝试从较新的Java编译,这里有一些说明:

The best way to compile for older Java is just to use the older JDK releases. But if you really want to try to compile for older Java from newer, here are some instructions:

  • How to cross-compile for older platform versions
  • Source, target, class file version decoder ring

这篇关于JRE 1.4是否支持使用Java 1.5和Linux编译的类。 1.6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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