javac源和目标选项 [英] javac source and target options

查看:115
本文介绍了javac源和目标选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了哪个JDK的发行版可以运行`javac -source 1.6 -target 1.5`?。我理解源和目标的各个选项。我不明白为什么源版本高于目标版本。编译旧目标的代码是有道理的。但在这种情况下,为什么我们不使用我们希望能够运行的最老目标的-source

I have seen the compile options like discussed in Which JDK's distributions can run `javac -source 1.6 -target 1.5`?. I understand the individual options for source and target. I don't understand why source version is higher that the target version. Compiling the code for older targets makes sense. But in that case, why dont we just use -source of the oldest target we want to be able to run on

推荐答案

Java向后兼容。您可以使用 -source 选项指定用于编译的java版本,并使用 -target 选项指定要支持的最低java版本。例如。如果我指定1.4的目标,那么我的程序将无法在java 1.3或更低版本上运行。有关详细信息,请参阅以下javac 文档。特别是关于交叉编译选项

Java is backwards compatible. You use the -source option to specify the java version used for compilation and you use the -target option to specify the lowest java version to support. eg. If I specify a target of 1.4, then my program will not be able to run on java 1.3 or lower. see the following javac documentation for more info. especially the section on Cross-Compilation Options

这篇关于javac源和目标选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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