错误:无法创建 Java 虚拟机错误:发生致命异常。程序将退出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37186197/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:05:15  来源:igfitidea点击:

Error:could not create the Java Virtual Machine Error:A fatal exception has occured.Program will exit

javajava-8

提问by Maheshwar Reddy K

I have just installed Java SE Development Kit 8u91 on my 64 bit Windows-10 OS. I set my pathvariables . I tried java --versionin my command prompt it gave me an error.

我刚刚在我的 64 位 Windows-10 操作系统上安装了 Java SE Development Kit 8u91。我设置了我的路径变量。我在命令提示符中尝试了java --version它给了我一个错误。

c:\Users\Onlymanu>java --version
Unrecognized option: --version    
Error: Could not create the Java Virtual Machine. 
Error: A fatal exception has occurred. Program will exit.

But when i tried java -versionit worked.

但是当我尝试java -version 时它起作用了。

I tried initializing _JAVA_OPTIONSenvironment variable and ever tried re-installation none of them worked. Can any one help me please?

我尝试初始化_JAVA_OPTIONS环境变量并尝试重新安装它们都不起作用。任何人都可以帮助我吗?

回答by Ankur Singhal

Try executing below command,

尝试执行以下命令,

java -help

It gives option as,

它提供了选项,

-version print product version and exit

-version 打印产品版本并退出

java -versionis the correct command to execute

java -version是要执行的正确命令

回答by Dhaval Dalsania

I think you have put command like java -VERSION. This is in capital letters You need to put all command in lowercase letters

我想你已经把命令像java -VERSION. 这是大写字母你需要把所有命令都用小写字母

javac -version
java -version

All characters must be in lowercase letter

所有字符必须是小写字母

回答by Akash Perera

Your command is wrong.

你的命令是错误的

Linux

Linux

java -- version

java -- version

macOS

苹果系统

java -version

java -version

You can't use those commands other way around.

您不能以其他方式使用这些命令。

回答by Veli Mpinda

the command should be java -version

命令应该是java -version

回答by monti

java -version
java -showversion

Both commands work In Linux 16.04 LTS

这两个命令都适用于 Linux 16.04 LTS

回答by Santosh Sindham

--versionis a valid option from JDK 9 and it is not a valid option until JDK 8 hence you get the below:

--version是 JDK 9 中的有效选项,它在 JDK 8 之前不是有效选项,因此您会得到以下信息:

Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

You can try installing JDK 9 or any version later and check for java --versionit will work.

您可以尝试安装 JDK 9 或以后的任何版本并检查java --version它是否有效。

Alternately, from the installed JDK 9 or later versions you can see from java -helpthe below two options will be available:

或者,从已安装的 JDK 9 或更高版本中,您可以看到java -help以下两个选项可用:

    -version      print product version to the error stream and exit
    --version     print product version to the output stream and exit

where as in JDK 8 you will only have below when you execute java -help

与在 JDK 8 中一样,当您执行时,您将只有以下内容 java -help

    -version      print product version and exit

I hope it answers your question.

我希望它能回答你的问题。

回答by SaumyaAgnihotri

I was facing a similar issue. Actually the command is :

我面临着类似的问题。实际上命令是:

java -version and not java --version.

You will get output something like this:

你会得到这样的输出:

java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)