错误:无法创建Java虚拟机

时间:2012-10-09 21:33:42

标签: java netbeans

我已经访问了与我的问题相关的所有现有问题,但我仍有问题。所有安装都已正确安装。我使用的是最新的Netbeans版本。执行程序后,我有这个错误:

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

我的Netbeans.conf是:

# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/7.1.2"
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-client -J-Xss2m -J-Xms16m -J-XX:PermSize=16m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
# Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.
# You can find these values in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx or
# -J-XX:MaxPermSize= here or on the command line.
# If you specify the heap size (-Xmx) explicitly, you may also want to enable
# Concurrent Mark & Sweep garbage collector. In such case add the following
# options to the netbeans_default_options:
# -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled J-XX:+CMSPermGenSweepingEnabled
# (see http://wiki.netbeans.org/FaqGCPauses)
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="C:\Arquivos de programas\Java\jdk1.7.0_07"
# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"
# If you have some problems with detect of proxy settings, you may want to enable
# detect the proxy settings provided by JDK5 or higher.
# In such case add -J-Djava.net.useSystemProxies=true to the netbeans_default_options.

我该怎么办?我一直在努力解决这个错误。我的系统内存是3Gb。

4 个答案:

答案 0 :(得分:3)

  

无法为对象堆保留足够的空间

这几乎总意味着您的-Xmx对于机器来说太高了。上面有一条消息:

  

#注意默认为您选择-Xmx和-XX:MaxPermSize

尝试提供显式值,从小处开始。请注意,-Xms必须小于或等于-Xmx

答案 1 :(得分:2)

我们为上述问题提供了几种解决方案

解决方案1:您可以重新安装所有组件。即它意味着你已经安装了整个s / w。 错误:无法创建Java虚拟机。

解决方案2:最大堆大小根据机器架构而变化,例如32位或64位,JVM位大小,例如32位JVM或64位JVM和操作系统。

在32位机器中,尽管最大堆大小的理论极限是4GB,但它在操作系统上与操作系统不同,例如由于各种原因,在32位Windows XP上最大堆大小限制高达1.5G,而在64位Solaris机器上,即使使用32位JVM,也可以承受大约3.5GB的容量。所以当你在32位Windows XP机器上运行以下java命令时

解决方案3:提供堆空间时,还有一个值得注意的语法错误是数字文字和单位之间的空间,如下例所示:

Correct: ~/java java -Xmx1500 M
In-correct:   ~/java java -Xmx1500MB
In-Correct:  ~/java java -Xmx 1400M 

答案 2 :(得分:2)

我在启动Netbeans

时遇到了同样的错误
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

我尝试多次重启Netbeans。同样的错误正在重复。后来我发现它正在发生,因为其他一些应用程序已经在使用JVM。所以我找了一个Tomcat Server的应用程序。我终止Tomcat并尝试再次启动Netbeans,这很好。因此,请尝试查找使用JVM的任何应用程序。

答案 3 :(得分:1)

  

-J-Xss2m -J-Xms16m -J-XX:PermSize = 16m

这些价​​值不足。尝试将其从16Mb增加到512Mb(或1Gb)