Java“VM 初始化期间发生错误”修复?

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

Java "Error occurred during initialization of VM" fix?

javainitializationvirtual-machine

提问by user3066803

I was trying to make a Minecraft server and got the following error on startup:

我试图制作一个 Minecraft 服务器并在启动时出现以下错误:

Error occured during initialization of VM Could not reserve enough space for object heap Error: Could not create the Java Virtual Machine Error: A fatal exception has occurred. Program will exit.

VM 初始化期间发生错误无法为对象堆保留足够的空间错误:无法创建 Java 虚拟机错误:发生了致命异常。程序将会退出。

I tried everything I could find: I created CLASS and CLASSPATH environmental variables that went to my Java's bin folder. I re-installed java, making sure it was 64 bit, as my computer is. Still, I get this error. Does anyone know a solution?

我尝试了所有我能找到的方法:我创建了 CLASS 和 CLASSPATH 环境变量,这些变量放到了我的 Java 的 bin 文件夹中。我重新安装了 java,确保它是 64 位的,就像我的电脑一样。尽管如此,我还是收到了这个错误。有谁知道解决方案?

回答by Rogue

You are attempting to allocate more RAM than your system will allow you to allocate.

您正在尝试分配比系统允许分配更多的 RAM。

In your startup script, lower the values of your Xmx/Xms arguments.

在您的启动脚本中,降低 Xmx/Xms 参数的值。

回答by Melih Alt?nta?

Run the JVM with -XX:MaxHeapSize=256m(or any big number), and possibly -Xmx512m

使用-XX:MaxHeapSize=256m(或任何大数字)运行 JVM ,并且可能-Xmx512m

回答by user3608737

I've actually noticed this issue when you try and take a dump of a service running java. Try using psexec -s to execute your dump

当您尝试转储运行 java 的服务时,我实际上已经注意到了这个问题。尝试使用 psexec -s 执行转储

I'm not sure why this seems to work on some servers and not others

我不确定为什么这似乎适用于某些服务器而不适用于其他服务器

回答by Erik

I had this same error. Running the cmd as Administrator resolved it.

我有同样的错误。以管理员身份运行 cmd 解决了它。

回答by h3xh4wk

I encountered this error when I was trying to build selenium webdriver. as suggested above by Rogue that we need to reduce the allocated memory in the arguments.

我在尝试构建 selenium webdriver 时遇到了这个错误。正如上面 Rogue 所建议的,我们需要减少参数中分配的内存。

I changed java heap size arguments as below

我改变了java堆大小参数如下

java $JAVA_OPTS -Xmx256m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=256m -jar third_party/jruby/jruby-complete.jar -X-C -S rake $*

回答by Yasir Shabbir Choudhary

I also faced this issue by My IntellijIDEA allocate more jvm memory space than system allocated. My issued is resolved through just uninstall the JDK and install it again.

我的 IntellijIDEA 分配的 jvm 内存空间比系统分配的多,我也遇到了这个问题。我的问题是通过卸载JDK并重新安装来解决的。

回答by JNetputne

It happened to me also. My eclipse would not run. Uninstalled and reinstalled eclipse like 3 time and no luck. Came to this question during a google search, and Yasir's answer helped me out, because I also had IntelliJ installed into my DEV BOX recently. So deleted C:\Program Files\Java folder and reinstalled java into default install folder and it worked. I also had jdk in my system path from previous setup.

它也发生在我身上。我的日食不会运行。卸载并重新安装 eclipse 3 次,但没有运气。在谷歌搜索期间遇到了这个问题,Yasir 的回答帮助了我,因为我最近还在我的 DEV BOX 中安装了 IntelliJ。因此删除了 C:\Program Files\Java 文件夹并将 java 重新安装到默认安装文件夹中,并且它起作用了。我之前设置的系统路径中也有 jdk。