是否可以使用可在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?

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

问题描述

由于公共Java 6 SE JRE越来越接近它的EOL(11月12日),我正在考虑将我的项目从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编译器/ code>选项。但是如果你使用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天全站免登陆