简体   繁体   English

错误:无法创建Java虚拟机Mac OSX Mavericks

[英]Error: Could not create the Java Virtual Machine Mac OSX Mavericks

I just installed the latest Java SDK 7-67 from Oracle on the Mac 10.9.4. 我刚刚在Mac 10.9.4上安装了Oracle的最新Java SDK 7-67。 I then ran the command java -v in Terminal and I get this message: 然后我在终端中运行命令java -v ,我收到此消息:

Error: Could not create the Java Virtual Machine. 错误:无法创建Java虚拟机。
Error: A fatal exception has occurred. 错误:发生了致命异常。 Program will exit. 程序将会退出。

Normally this error occurs when you invoke java by supplying the wrong arguments/options. 通常,当您通过提供错误的参数/选项来调用java时会发生此错误。 In this case it should be the version option. 在这种情况下,它应该是version选项。

java -version

So to double check you can always do java -help , and see if the option exists. 所以要仔细检查你总是可以做java -help ,看看该选项是否存在。 In this case, there is no option such as v . 在这种情况下,没有诸如v选项。

if you tried running java with -version argument, and even though the problem could not be solved by any means, then you might have installed many java versions, like JDK 1.8 and JDK 1.7 at the same time. 如果您尝试使用-version参数运行java ,即使无法通过任何方式解决问题,那么您可能已经同时安装了许多Java版本,如JDK 1.8和JDK 1.7。

So try uninstalling all other versions other than the one you need , then set the JAVA_HOME path variable for that JDK remaining, and you're done. 因此, 尝试卸载所需的所有其他版本 ,然后为剩余的JDK设置JAVA_HOME路径变量,然后就完成了。

Unrecognized option: - Error: Could not create the Java Virtual Machine. 无法识别的选项: - 错误:无法创建Java虚拟机。 Error: A fatal exception has occurred. 错误:发生了致命异常。 Program will exit. 程序将会退出。

I was getting this Error due to incorrect syntax using in the terminal. 由于在终端中使用了错误的语法,我收到此错误。 I was using java - version. 我使用的是java版本。 But its actually is java -version. 但它实际上是java -version。 there is no space between - and version. - 和版本之间没有空格。 you can also cross check by using java -help. 你也可以使用java -help进行交叉检查。

i hope this will help. 我希望这将有所帮助。

There can be one more reason for such behavior - you delete current working directory. 这种行为还有一个原因 - 您删除当前的工作目录。

For example: 例如:

# in terminal #1
cd /home/user/myJavaApp

# in terminal #2
rm -rf /home/user/myJavaApp

# in terminal #1
java -jar myJar.jar

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

So try uninstalling all other versions other than the one you need, then set the JAVA_HOMEpath variable for that JDK remaining, and you're done. 因此,请尝试卸载所需的所有其他版本,然后为剩余的JDK设置JAVA_HOMEpath变量,然后就完成了。

That's worked for me, I have two JDK (version 8 & 11) installed on my local mac, that causes the issue, for uninstalling, I followed these two steps: 这对我有用,我在我的本地mac上安装了两个JDK(版本8和11)导致问题,卸载时,我遵循以下两个步骤:

  • cd /Library/Java/JavaVirtualMachines cd / Library / Java / JavaVirtualMachines
  • rm -rf openjdk-11.0.1.jdk rm -rf openjdk-11.0.1.jdk

Try : java -version , then if you see java 11 尝试:java -version,然后如果你看到java 11

try to delete with terminal : cd /Library/Java/JavaVirtualMachines rm -rf openjdk-11.0.1.jdk 尝试使用终端删除:cd / Library / Java / JavaVirtualMachines rm -rf openjdk-11.0.1.jdk

if it doesn't try delete manually: 1) click on finder 2) go to folder 3) post /Library/Java/JavaVirtualMachines 4) delete java 11 . 如果没有尝试手动删除:1)点击查找器2)转到文件夹3)post / Library / Java / JavaVirtualMachines 4)删除java 11。

then try java version and you will see : java version "1.8.0_191" 然后尝试java版本,你会看到:java版本“1.8.0_191”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM