问题
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