javac -version 显示什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19783458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does javac -version show?
提问by Farrukh Chishti
Even the official documentation of javac
says nothing about the -version option.
采纳答案by Nasruddin
Javac -version tells you about the JDK version. That is, it gives the information of Compiler.
Javac -version 告诉您有关 JDK 版本的信息。也就是说,它给出了Compiler的信息。
回答by Dark Knight
This command outputs your java compiler's version. In mine case it shows 1.6.0
此命令输出您的 java 编译器的版本。在我的情况下,它显示1.6.0
回答by Adrian Shum
Official page does mention about it:
官方页面确实提到了它:
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javac.html
Why you cannot find on the page is, -version
is not available for javac
until Java 6 I believe (I am sure it is not available in 1.4 and before). That's why it is not showing on your page, which is javac
ref page for Java 1.5. However, go to java
command reference page of Java 1.5 and you should be able to find the -version
switch.
为什么你在页面上找不到,我相信直到 Java 6-version
才可用javac
(我确定它在 1.4 及之前不可用)。这就是为什么它没有显示在您的页面上,这是javac
Java 1.5 的参考页面。但是,转到java
Java 1.5 的命令参考页面,您应该能够找到-version
开关。
回答by Stephen C
You are looking at the official documentation for an OBSOLETEversion of javac
Java 5. The -version
option is documented in the javac
manual entry for Java 6 and Java 7.
您正在查看Java 5 OBSOLETE版本的官方文档javac
。该-version
选项记录在javac
Java 6 和 Java 7的手册条目中。
And in response to your question about what -version
actually shows (for javac
and java
) the best answer is "unspecified" or "it depends on what version / platform you are using". In practice, your best bet is to just try it for yourself.
并回答您关于-version
实际显示(javac
和java
)什么的问题,最佳答案是“未指定”或“这取决于您使用的版本/平台”。在实践中,最好的办法就是亲自尝试一下。
If your reason for asking is that you want to extract some useful information about the Java platform from the version strings ... I recently tried searching for a web page that listed the version strings for the java
command, and came up empty. A better approach would probably be to write a tiny Java application to print out the relevant properties from the System
properties object. The javadoc for System
lists a number of properties that are standardised.
如果您询问的原因是想从版本字符串中提取一些有关 Java 平台的有用信息……我最近尝试搜索一个列出java
命令版本字符串的网页,但结果为空。更好的方法可能是编写一个小型 Java 应用程序来打印System
属性对象中的相关属性。javadoc forSystem
列出了许多标准化的属性。
回答by Gimby
Just to expand, both display the same; the version of Java that the tools are part of.
只是为了扩展,两者显示相同;工具所属的 Java 版本。
You can ASSUME that what one reports, the other will automatically also report and so it is overkill to have the option in both. Until the moment you encounter a machine where there are multiple versions of Java installed and you can compile something yet you can't run it. Displaying the versions of javac and java can then quickly tell you that the setup of the machine is messed up enough that different versions of Java are being used to compile and run. And then you thank the designers for adding it in.
您可以假设一个报告的内容,另一个也会自动报告,因此在这两个选项中都有这个选项是多余的。直到您遇到一台安装了多个 Java 版本的机器,并且您可以编译某些东西但无法运行它。显示 javac 和 java 的版本可以很快告诉你机器的设置已经搞砸了,以至于使用不同版本的 Java 来编译和运行。然后你感谢设计师添加它。