在Java 8和Java 11中使用--version和-version进行版本检查 [英] Version check with --version and -version in Java 8 and Java 11

查看:2459
本文介绍了在Java 8和Java 11中使用--version和-version进行版本检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 11

JAVA_HOME : C:\Program Files\Java\jdk-11.0.4

我能够使用以下命令在cmd中找到Java版本:

I was able to find Java version in cmd with following command:

java --version  //successfully executed

java -version  //successfully executed

Java 8

 JAVA_HOME : C:\Program Files (x86)\Java\jdk1.8.0_231

我能够使用以下命令在cmd中找到Java版本:

I was able to find Java version in cmd with following command:

java -version  //successfully executed

我无法使用--version命令找到Java版本

while I was unable to find java version with --version command

java --version  //not successfully executed

为什么在执行--version时出现无法创建Java虚拟机的错误,或者在 jdk 8 中仅此命令选项不可用?如果它是在jdk 11中添加的,那么它在doc中提到了什么地方?

Why I get error that Java Virtual Machine could not be created when I execute --version, or just this command option not available in jdk 8? If it was added in jdk 11 then where is it mentioned in doc?

推荐答案

该选项是Java 9中引入的.

The option was introduced in Java 9.

如果您搜索--version,请参见此处.这是它出现在java工具文档中的第一个版本(java工具的

See here, if you search for --version it's the first version in which it appears in the java tool's documentation (the java tool's documentation for Java 8 doesn't mention it).

这篇关于在Java 8和Java 11中使用--version和-version进行版本检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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