我在 Ubuntu Destkop 14.04 LTS 中從控制台建立了一個用戶,執行以下操作:
sudo addgroup hadoop
sudo adduser --ingroup hadoop hduser
我使用該用戶執行各種操作,因為我使用它執行一些與 hadoop 相關的程式設計操作,所以我知道它運作得很好,總是從控制台使用它並在沒有 GUI 的情況下執行東西。我想用這個用戶打開一個 Eclipse (Luna),所以,我這樣做:
su hduser
cd /opt/eclipse
./eclipse
但它給我一個錯誤:
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
at org.eclipse.swt.SWT.error(SWT.java:4467)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:934)
at org.eclipse.swt.widgets.Display.create(Display.java:918)
at org.eclipse.swt.graphics.Device.<init>(Device.java:157)
at org.eclipse.swt.widgets.Display.<init>(Display.java:514)
at org.eclipse.swt.widgets.Display.<init>(Display.java:505)
at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:732)
at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:162)
at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay$
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEAppl$
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHand$
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runAppl$
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(E$
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.j$
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.j$
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl$
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce$
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
但是,如果我使用我的「主用戶」(與我用於登入 ubuntu destkop 的用戶相同)從控制台開啟 eclipse,則 eclipse 會完全正常開啟。
這就是為什麼我懷疑兩個用戶之間存在的差異不允許我這樣做,而且我懷疑問題在於高畫質用戶沒有在圖形環境中使用的正確配置。我說得對嗎?可以修改 hduser 讓我打開 eclipse 嗎?
答案1
嘗試執行這個指令:
export DISPLAY=:0
它確保在執行 Eclipse 之前知道要使用哪個 X 顯示。
如果這不起作用,該使用者可能還需要視窗管理器的設定檔。因此,只需執行 GUI 路由即可新增使用者(我相信它位於首選項 → 使用者和群組)因此所有預設配置都會被載入。
答案2
我在 CentOS 6.x 上安裝 IBM Installation Manager (IBMIM) 時遇到了類似的問題,並透過安裝幾個導致此相同錯誤的軟體包來解決該問題:
$ sudo /opt/IBM/InstallationManager/eclipse/IBMIM \
-record /root/was8nd_v85_install.xml \
-skipInstall /tmp/was8nd
00:00.46 ERROR [main] org.eclipse.equinox.log.internal.ExtendedLogReaderServiceFactory safeLogged
Application error
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
at org.eclipse.swt.SWT.error(SWT.java:4387)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:913)
at org.eclipse.swt.widgets.Display.create(Display.java:899)
at org.eclipse.swt.graphics.Device.<init>(Device.java:156)
...
IBMIM:
An error has occurred. See the log file
/opt/IBM/InstallationManager/eclipse/configuration/1457978953529.log.
解決方案第 1 部分 - 缺少軟體包
$ sudo yum install \
gtk2 \
libXtst \
gnome-desktop \
xorg-x11-xauth \
dejavu-lgc-sans-fonts
類似的事情也可以在 Ubuntu 上完成。
解決方案第 2 部分 - xauth
出現的另一個問題是您嘗試透過 sudo 以 root 使用者身分執行 IBMIM 安裝程式(基於 Eclipse)。當您執行此操作時,您將從安裝程式中收到上述應用程式錯誤:
00:00.46 ERROR [main] org.eclipse.equinox.log.internal.ExtendedLogReaderServiceFactory safeLogged
Application error
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
要解決此問題,您需要將xauth add
登入的初始使用者新增至 root$HOME/.Xauthority
檔案中。
作為用戶1:
$ xauth list
ip-10-10-10-10.us-west-1.compute.internal/unix:10 MIT-MAGIC-COOKIE-1 6902e8c245a01ca50XXXXXXXXXXXXXXXX
然後以 root 身分:
$ xauth add ip-10-10-10-10.us-west-1.compute.internal/unix:10 MIT-MAGIC-COOKIE-1 6902e8c245a01ca50XXXXXXXXXXXXXXXX
xauth: creating new authority file /root/.Xauthority
$ xauth list
ip-10-10-10-10.us-west-1.compute.internal/unix:10 MIT-MAGIC-COOKIE-1 6902e8c245a01ca50XXXXXXXXXXXXXXXX