Linux – Open eclipse with a linux user that doesn’t have graphical environment (created from console)

eclipsehadooplinuxUbuntu

I created an user from console in my Ubuntu Destkop 14.04 LTS, doing this:

sudo addgroup hadoop
sudo adduser --ingroup hadoop hduser

I used that user for doing all sort of stuff, because i'm using it for doing some programming stuff that is related to hadoop, so i know that it works fine, always using it from console and executing stuff without a GUI.
And i want to open, with this user, an Eclipse (Luna), so, i do this:

su hduser
cd /opt/eclipse
./eclipse

But it throws me an error:

!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)

But, if i open eclipse from console using my "main user" (the same that i used for loging into my ubuntu destkop), the eclipse opens perfectly fine.

That's why i suspect that the difference existing between both users doesn't let me do this, and i suspect that the problem is that hduser doesn't have the proper configurations for being used in a graphical environment. I'm righ? Can be hduser modified in a way that let me open eclipse?

Best Answer

Try executing this command:

export DISPLAY=:0

It makes sure it knows which X display to use before executing Eclipse.

If that doesn't work, this user may also need to have configuration files for a window manager. So just do the GUI route for adding a new user (I believe it's under Preferences → Users and Groups) so all the default configs are loaded.

Related Question