错误:无法创建 Java 虚拟机 Mac OSX Mavericks
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25609405/
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
Error: Could not create the Java Virtual Machine Mac OSX Mavericks
提问by user1574598
I just installed the latest Java SDK 7-67 from Oracle on the Mac 10.9.4. I then ran the command java -v
in Terminal and I get this message:
我刚刚在 Mac 10.9.4 上安装了来自 Oracle 的最新 Java SDK 7-67。然后我java -v
在终端中运行命令并收到此消息:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
错误:无法创建 Java 虚拟机。
错误:发生了致命异常。程序将会退出。
采纳答案by BatScream
Normally this error occurs when you invoke java by supplying the wrong arguments/options. In this case it should be the version
option.
通常,当您通过提供错误的参数/选项调用 java 时会发生此错误。在这种情况下,它应该是version
选项。
java -version
So to double check you can always do java -help
, and see if the option exists. In this case, there is no option such as v
.
所以要仔细检查你总是可以做java -help
,看看选项是否存在。在这种情况下,没有诸如 的选项v
。
回答by Alex Povar
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.
回答by Amaresh HD
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.
如果您尝试java
使用-version
参数运行,即使无法通过任何方式解决问题,那么您可能同时安装了许多 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.
因此,尝试卸载除您需要的版本之外的所有其他版本,然后JAVA_HOME
为剩余的 JDK设置路径变量,您就完成了。
回答by Rahul
Unrecognized option: - Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
无法识别的选项: - 错误:无法创建 Java 虚拟机。错误:发生了致命异常。程序将会退出。
I was getting this Error due to incorrect syntax using in the terminal. I was using java - version. But its actually is java -version. there is no space between - and version. you can also cross check by using java -help.
由于在终端中使用的语法不正确,我收到此错误。我正在使用 java - 版本。但它实际上是 java -version。- 和版本之间没有空格。您还可以使用 java -help 进行交叉检查。
i hope this will help.
我希望这将有所帮助。
回答by Jiangtao Liu
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
- rm -rf openjdk-11.0.1.jdk
- cd /Library/Java/JavaVirtualMachines
- rm -rf openjdk-11.0.1.jdk
回答by Tal Hakmon
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) 发布 /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”