Version check with --version and -version in Java 8 and Java 11

邮差的信 提交于 2020-01-23 18:54:07

问题


Java 11

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

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

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

java -version  //successfully executed

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

java --version  //not successfully executed

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?


回答1:


The option was introduced in Java 9.

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).



来源:https://stackoverflow.com/questions/59152510/version-check-with-version-and-version-in-java-8-and-java-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!