我在用Eclipse的最新版Java EE Kepler(v4.3.0),安裝完JBoss Developer Studio 7(Kepler)後,再次啟動Eclipse,彈出Failed to create the Java Virtual Machine的錯誤。確認後就會自動結束。
原因分析:
安裝完JBoss Developer Studio 7(Kepler)後,對Eclipse安裝目錄下的eclipse.ini檔案重新寫入新的參數導致。
源檔案:
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20130521-0416
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m
修改後:
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20130521-0416
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms256m
-Xmx1024m
-Djboss.discovery.directory.url=https://devstudio.jboss.com/updates/7.0/devstudio-directory.xml
可以看到,-Xms和-Xmx的參數被改大了,啟動時系統不能為其分配足夠的記憶體導致這個錯誤的出現。
解決方案:
-Xms不變,將-Xmx的參數修改為512m即可。