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

查看:27
本文介绍了JRE 1.4 是否支持使用 Java 1.5 & 编译的类?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.

更新:我确认如果您在 JRE 1.4 上运行 1.6 类文件,您会收到 java.lang.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 编译为较旧的 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:

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

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