在Java 1.7上编译Java 1.5仍然有效吗? [英] Will compiling for Java 1.5 on Java 1.7 still work?

查看:196
本文介绍了在Java 1.7上编译Java 1.5仍然有效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在我的一个项目中转到Java 7。我声称它可以在Java 1.5上运行,因为我在Java 6或7中没有任何依赖。但是在今天编译时我注意到了这一点:

I've recently moved to Java 7 in one of my projects. I claim that it can run on Java 1.5 simply because there's nothing I depend on that is in Java 6 or 7. However when compiling today I noticed this:

bootstrap class path not set in conjunction with -source 1.5

Google发现很少有关此警告的信息。这是否意味着您无法从Java 1.7编译到Java 1.5?

Google has found little information on this warning. Does this mean that you can't compile to Java 1.5 from Java 1.7?

推荐答案

此Oracle博客解释了警告:

This Oracle blog explains the warning:

http://blogs.oracle.com/ darcy / entry / bootclasspath_older_source

原因是,如果你没有为旧平台设置rt.jar,那么:

The reason is, that if you fail to set rt.jar for the older platform, then:


如果不采取第二步,javac将尽职尽责地使用旧的
语言规则与新库相结合,这可能导致
类因为对
不存在的方法的引用可以包含在旧平台上不起作用的文件。

If the second step is not taken, javac will dutifully use the old language rules combined with new libraries, which can result in class files that do not work on the older platform since references to non-existent methods can get included.

这篇关于在Java 1.7上编译Java 1.5仍然有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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