四月 22nd, 2011

Eclipse出现java was started but returned exit code 1报错并退出的解决方法

技术杂谈, by 陈威.
热度:

      最近在使用Eclipse时发现无法启动,或者启动后经常出现崩溃退出的情况,提示的错误信息都是“java was started but returned exit code 1”,下载安装了最新版的Eclipse后还是没有解决问题。无奈之下只好百度之,翻了好几页都没有发现有用的信息,直接换到Google.com,终于在Eclipse Forum找到了一个靠谱的答案(网址是http://www.eclipse.org/forums/index.php?t=tree&goto=547573&#page_top),回答答案是“Eclipse is using the system default JRE that it finds in the windows system folders. You should point it to a JDK installation using eclipse.ini (as described here: http://wiki.eclipse.org/Eclipse.ini )”,大意是Eclipse启动的时候默认会使用从windows系统目录下找到的JRE作为默认的环境,由于我之前升级安装了一下JDK,所以系统目录下的JRE和实际的Java安装是不匹配的,因此会出现运行Eclipse时报错的情况。
解决方案:
      根据eclipse.ini文件的说明(http://wiki.eclipse.org/Eclipse.ini),该文件提供指定运行eclipse的JVM功能,需要在eclipse.ini中加入JVM的路径说明。语法很简单:

-vm
C:\Program Files\Java\jdk1.6.0_22\bin\javaw.exe

      eclipse.ini说明文档中特别提到使用-vm参数的注意事项:
(1)The -vm option and its value (the path) must be on separate lines.(-vm选项和其对应的javaw.exe的路径必须各占一行,这应该是参数解析的格式要求)
(2)The value must be the full absolute path to the Java executable, not just to the Java home directory.(指定的虚拟机路径必须是指向可执行Java程序的完整绝对路径,不能只指定到Java_HOME目录。这个好理解,要指定JVM的话肯定要指定到具体的可执行文件去)
(3)The -vm option must occur before the -vmargs option, since everything after -vmargs is passed directly to the JVM.(-vm选项必须放在-vmargs选项前,这是因为-vmargs选项后的值都是作为JVM的参数传给虚拟机的,如果-vm放在-vmargs之后就没有意义了。而-vmargs选项中一般可指定-Xms和-Xmx这两个内存参数)

Back Top

使用JDK 1.6自带的jvisualvm监控远程服务器中Java程序资源占用情况 MyEclipse安装SubClipse SVN插件

Responses to “Eclipse出现java was started but returned exit code 1报错并退出的解决方法”

  1. 没有任何评论。
  1. 没有任何引用。

发表回复

Back Top

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word