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

6,474

Solution 1

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.

Solution 2

I ran into a similar problem while installing IBM Installation Manager (IBMIM) on CentOS 6.x and worked around the issue by installing several packages which were the cause of this identical error:

$ 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.

Solution part 1 - missing packages

$ sudo yum install \
   gtk2            \
   libXtst         \
   gnome-desktop   \
   xorg-x11-xauth  \
   dejavu-lgc-sans-fonts 

Something similar to this could've been done on Ubuntu as well.

Solution part 2 - xauth

The other issue that'll arise is you're attempting to run the IBMIM installer (Eclipse based) as the root user via sudo. When you do this you'll get the above Application error from the installer:

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]

To work around this you'll need to use xauth add to add the initial user you logged in as to root's $HOME/.Xauthority file.

As user1:

$ xauth list
ip-10-10-10-10.us-west-1.compute.internal/unix:10  MIT-MAGIC-COOKIE-1  6902e8c245a01ca50XXXXXXXXXXXXXXXX

Then as 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

References

Share:
6,474

Related videos on Youtube

chomp
Author by

chomp

I work with java in my job, mostly software related to economics. And i'm developing a thesis also related to hadoop and giraph, so probably you should see a lot of questions about this topics made by me ;) SOreadytohelp

Updated on September 18, 2022

Comments

  • chomp
    chomp over 1 year

    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?

    • chomp
      chomp almost 9 years
      I updated hduser for being able to log in properly into ubuntu, in hope of this could be helpful for solving the problem of this user for executing eclipse, but it didn't work. Also, i set all the files with the same sets of permissions chmod -R 777 /opt/eclipse/*. The problem remains.
  • chomp
    chomp almost 9 years
    Hi @professor-blargin, thank you for your answer. I tryed export DISPLAY=:0 but the same error persists (org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]). Also, i couldn't add a new user from "Users and Groups", because it already exists there. Any other idea?
  • warhansen
    warhansen over 5 years
    I tried this but I get: xauth: file /home/xxxx/.Xauthority does not exist