是否可以使用可以在 Java 6 JVM 上运行的 Java 7 SDK 编译类文件? [英] Is it possible to compile class files with the Java 7 SDK which can run on Java 6 JVMs?

查看:32
本文介绍了是否可以使用可以在 Java 6 JVM 上运行的 Java 7 SDK 编译类文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于公共 Java 6 SE JRE 越来越接近 EOL(12 年 11 月),我正在考虑将我的项目从 Java 6 移植到 Java 7.如果 Apple 提供一个适用于 Mac OS X 的 Java 7 JRE.但由于 Apple 不愿意这样做,我仍然需要支持只有 Java 6 JRE 的用户.

Since the public Java 6 SE JRE is getting closer to it's EOL (Nov '12), I'm considering porting my projects from Java 6 to Java 7. This would'nt be a big deal, if Apple would provide a Java 7 JRE for Mac OS X. But since Apple isn't willing to do so, I still have to support users which only have a Java 6 JRE.

有没有办法用 Java 7 javac 编译 Java 6 兼容的二进制文件(类文件)?当然,我知道这样做时我无法使用新的 Java 7 功能.

Is there a way to compile Java 6 compatible binaries (class files) with the Java 7 javac? Certainly I'm aware that I can't use the new Java 7 features when doing so.

期待中的感谢!

推荐答案

视情况而定.如果您的程序不使用新的 Java 7 语言扩展,那么您可以使用 -source 1.6-target 1.6 选项运行 Java 编译器.但是如果您使用 Java 7 语言扩展,那么 -source 1.6 将导致编译错误.

It depends. If your program doesn't use the new Java 7 language extensions, then you can run the Java compiler with the -source 1.6 and -target 1.6 options. But if you use Java 7 language extensions then -source 1.6 will result in compilation errors.

当然,我知道这样做时我无法使用新的 Java 7 功能.

Certainly I'm aware that I can't use the new Java 7 features when doing so.

这包括 Java 7 语言特性......以及对 Java 7 对标准类库 API 更改的依赖.另请注意,有少量行为差异(即 API 错误修复)可能会导致代码在 Java 6 和 Java 7 上的运行方式不同.应在 Java 6 到 Java 7 转换文档中对其进行描述.

That includes Java 7 language features ... and dependencies on Java 7 changes to the standard class library APIs. Also be aware that there are small number of behavioural differences (aka API bug fixes) that may cause code to run differently on Java 6 and Java 7. They should be described in the Java 6 to Java 7 transition document.

更新 - 无论如何,这对您来说可能不再是问题,因为 Oracle 已经发布了适用于 Mac OSX 的 Java 7.

UPDATE - This probably no longer an issue for you anyway, because Oracle have released Java 7 for Mac OSX.

这篇关于是否可以使用可以在 Java 6 JVM 上运行的 Java 7 SDK 编译类文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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