想使用eclipse来尝试开发Android, 结果eclipse classic版本在ubuntu下竟然挂了,找了许久才找到solution, 做个标记。
系统环境:
ubuntu 10.04 (从9.10中更新而来的)
eclipse-java-ganymede-linux-gtk
现象:
启动eclipse classic版本,最后只弹一个空白提示框,无法 [关闭] 或 [确定]
出错日志分析:
查看工作空间下的".metadata/.log",报错信息主要有以下两方面:
java.lang.RuntimeException: Widget disposed too early!
org.eclipse.swt.SWTError: XPCOM error -2147467262
java.lang.RuntimeException: Widget disposed too early! at org.eclipse.ui.internal.WorkbenchPartReference$1.widgetDisposed(WorkbenchPartReference.java:171) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:117) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1158) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1182) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1163) at org.eclipse.swt.widgets.Widget.release(Widget.java:1026) at org.eclipse.swt.widgets.Control.release(Control.java:3217) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:1184) at org.eclipse.swt.widgets.Widget.release(Widget.java:1029) at org.eclipse.swt.widgets.Control.release(Control.java:3217) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:1184) at org.eclipse.swt.widgets.Widget.release(Widget.java:1029) at org.eclipse.swt.widgets.Control.release(Control.java:3217) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:1184) at org.eclipse.swt.widgets.Canvas.releaseChildren(Canvas.java:211) at org.eclipse.swt.widgets.Decorations.releaseChildren(Decorations.java:466) at org.eclipse.swt.widgets.Shell.releaseChildren(Shell.java:1948) at org.eclipse.swt.widgets.Widget.release(Widget.java:1029) at org.eclipse.swt.widgets.Control.release(Control.java:3217) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:442) at org.eclipse.swt.widgets.Shell.dispose(Shell.java:1893) at org.eclipse.swt.widgets.Display.release(Display.java:3083) at org.eclipse.swt.graphics.Device.dispose(Device.java:237) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:129) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
org.eclipse.swt.SWTError: XPCOM error -2147467262 at org.eclipse.swt.browser.Mozilla.error(Mozilla.java:1597) at org.eclipse.swt.browser.Mozilla.setText(Mozilla.java:1820) at org.eclipse.swt.browser.Browser.setText(Browser.java:737) at org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation.generateContentForPage(BrowserIntroPartImplementation.java:252) at org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation.dynamicStandbyStateChanged(BrowserIntroPartImplementation.java:451) at org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation.doStandbyStateChanged(BrowserIntroPartImplementation.java:658) at org.eclipse.ui.internal.intro.impl.model.AbstractIntroPartImplementation.standbyStateChanged(AbstractIntroPartImplementation.java:249) at org.eclipse.ui.internal.intro.impl.model.IntroPartPresentation.standbyStateChanged(IntroPartPresentation.java:443) at org.eclipse.ui.intro.config.CustomizableIntroPart.standbyStateChanged(CustomizableIntroPart.java:266) at org.eclipse.ui.internal.ViewIntroAdapterPart$2.run(ViewIntroAdapterPart.java:74) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.internal.ViewIntroAdapterPart.setStandby(ViewIntroAdapterPart.java:70) at org.eclipse.ui.internal.ViewIntroAdapterPart$1.propertyChanged(ViewIntroAdapterPart.java:55) at org.eclipse.ui.internal.WorkbenchPartReference.fireInternalPropertyChange(WorkbenchPartReference.java:374) at org.eclipse.ui.internal.WorkbenchPartReference.fireZoomChange(WorkbenchPartReference.java:539) at org.eclipse.ui.internal.PartPane.setZoomed(PartPane.java:349) at org.eclipse.ui.internal.PartStack.setZoomed(PartStack.java:1526) at org.eclipse.ui.internal.PartSashContainer.zoomIn(PartSashContainer.java:884) at org.eclipse.ui.internal.PartSashContainer.childRequestZoomIn(PartSashContainer.java:905) at org.eclipse.ui.internal.LayoutPart.requestZoomIn(LayoutPart.java:354) at org.eclipse.ui.internal.PartStack.setState(PartStack.java:1501) at org.eclipse.ui.internal.WorkbenchPage.setState(WorkbenchPage.java:3872) at org.eclipse.ui.internal.WorkbenchPage.toggleZoom(WorkbenchPage.java:3944) at org.eclipse.ui.internal.WorkbenchIntroManager.setIntroStandby(WorkbenchIntroManager.java:201) at org.eclipse.ui.internal.WorkbenchIntroManager.showIntro(WorkbenchIntroManager.java:136) at org.eclipse.ui.application.WorkbenchWindowAdvisor.openIntro(WorkbenchWindowAdvisor.java:173) at org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor.openIntro(IDEWorkbenchWindowAdvisor.java:458) at org.eclipse.ui.internal.WorkbenchWindow.open(WorkbenchWindow.java:777) at org.eclipse.ui.internal.Workbench$22.runWithException(Workbench.java:1041) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3378) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3036) at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803) at org.eclipse.ui.internal.Workbench$27.runWithException(Workbench.java:1361) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3378) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3036) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2293) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
分析:
以前运行过eclipse-jee版本,并无出现此问题,所以多数情况与classic版本带的swt相关。
尝试修改eclipse用一个启动脚本启动(eclipse-win.sh),使之以window窗体模式启动,但无效。
#!/bin/sh
export GDK_NATIVE_WINDOWS=1
/home/lsm/web/eclipse/eclipse
(以上脚本可以解决eclipse中某些确认按钮无法按下去的问题
)
借鉴网上的解决方案:
https://www-304.ibm.com/support/docview.wss?uid=swg21265773 (英文)
http://blog.sina.com.cn/s/blog_627399080100qnaj.html (简单)
http://sunshineyao.iteye.com/blog/836985
https://bugzilla.redhat.com/show_bug.cgi?id=483832
主要是因为firefox修改了xulrunner环境导致eclipse找不到xulrunner环境从而不能加载内置窗口。
解决方法(最简单):
在eclipse.ini的vmargs后面加上
-Dorg.eclipse.swt.browser.XULRunnerPath=/usr/lib/xulrunner
如下示例: -showsplash org.eclipse.platform -framework plugins/org.eclipse.osgi_3.4.0.v20080605-1900.jar -vmargs -Dorg.eclipse.swt.browser.XULRunnerPath=/usr/lib/xulrunner -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx256m -XX:MaxPermSize=256m
经尝试,当第一次能启动后,eclipse.ini部分配置会写在工作工间的".metadata"里。
即使你删除了-Dorg.eclipse.swt.browser.XULRunnerPath=/usr/lib/xulrunner,eclipse仍然可以启动。
其他解决方法不深入研究。
总结:
Eclipse不能启动,应当尝试去查看metadata里的日志信息,获取最直接的出错原因。