"No X11 DISPLAY variable" - what does it mean?

567,467

Solution 1

If you're on the main display, then

export DISPLAY=:0.0

or if you're using csh or tcsh

setenv DISPLAY :0.0

before running your app.

Actually, I'm surprised it isn't set automatically. Are you trying to start this application from a non-graphic terminal? If not, have you modified the default .profile, .login, .bashrc or .cshrc?

Note that setting the DISPLAY to :0.0 pre-supposes that you're sitting at the main display, as I said, or at least that the main display is logged on to your user id. If it's not logged on, or it's a different userid, this will fail.

If you're coming in from another machine, and you're at the main display of that machine and it's running X, then you can use "ssh -X hostname" to connect to that host, and ssh will forward the X display back. ssh will also make sure that the DISPLAY environment variable is set correctly (providing it isn't being messed with in the various dot files I mentioned above). In a "ssh -X" session, the DISPLAY environment variable will have a value like "localhost:11.0", which will point to the socket that ssh is tunnelling to your local box.

Solution 2

you must enable X11 forwarding in you PuTTy

to do so open PuTTy, go to Connection => SSH => Tunnels and check mark the Enable X11 forwarding

Also sudo to server and export the below variable here IP is your local machine's IP

export DISPLAY=10.75.75.75:0.0

enter image description here

Solution 3

Are you running this from within an X11 environment? You can use a terminal window, but it has to be within X (either after a graphical login, or by running startx).

If you're already within a graphical environment, try export DISPLAY=:0 for bash like shells (bash, sh, etc) or setenv DISPLAY :0 for C shell based shells (csh, tcsh, etc)

If you've connected from another machine via SSH, you use the -X option to display the graphical interface on the machine you're sitting at (provided there's an X server running there (such as xming for windows, and your standard Linux X server).

Solution 4

There are many ways to do this. I did something below convenient to me and always works fine.

  1. On your remote server, make sure to install xorg-x11-xauth, xorg-x11-font-utils, xorg-x11-fonts.
  2. Run the Xming Server on you local desktop
  3. On putty, before ssh to the server, enable the X11 forwarding and set the display location to localhost:0.0
  4. On the server, .Xauthority file is generated and notice that the DISPLAY variable is already set.

    $ xauth list

    $ xauth add

To test it, type xclock or xeyes

Note: To switch user, copy the .Xauthority file to the home directory of the respective user and also export the DISPLAY variable from that user.

Solution 5

One more thing that might be the problem in a case similar to described - X is not forwarded and $DISPLAY is not set when 'xauth' program is not installed on the remote side. You can see it searches for it when you run "ssh -Xv ip_address", and, if not found, fails, which's not seen unless you turn on verbose mode (a fail IMO). You can usually find 'xauth' in a package with the same name.

Share:
567,467

Related videos on Youtube

user42155
Author by

user42155

Updated on July 08, 2022

Comments

  • user42155
    user42155 almost 2 years

    I am trying to install a Java application on my Linux machine (Slackware).

    I have received the following error, and I do not understand it.

    Could you advise me how to approach the problem? Thank you.

    Here is what I get: (I see that some X11 DISPLAY variable needs to be set, but what value should I give it and how?)

    ~$ java -jar gate-5.0-beta1-build3048-installer.jar
    - ERROR -
    
    java.awt.HeadlessException:
    No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    java.awt.HeadlessException:
    No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    at java.awt.GraphicsEnvironment.checkHeadless(Graphic sEnvironment.java:159)
    at java.awt.Window.<init>(Window.java:407)
    at java.awt.Frame.<init>(Frame.java:402)
    at net.sourceforge.mlf.metouia.borders.MetouiaDotsBuf fer.<init>(MetouiaDotsBuffer.java:105)
    at net.sourceforge.mlf.metouia.borders.MetouiaDots.<i nit>(MetouiaDots.java:66)
    at net.sourceforge.mlf.metouia.borders.MetouiaToolBar Border.<init>(MetouiaToolBarBorder.java:49)
    at net.sourceforge.mlf.metouia.MetouiaLookAndFeel.ini tComponentDefaults(MetouiaLookAndFeel.java:241)
    at javax.swing.plaf.basic.BasicLookAndFeel.getDefault s(BasicLookAndFeel.java:130)
    at javax.swing.plaf.metal.MetalLookAndFeel.getDefault s(MetalLookAndFeel.java:1591)
    at javax.swing.UIManager.setLookAndFeel(UIManager.jav a:537)
    at javax.swing.UIManager.setLookAndFeel(UIManager.jav a:581)
    at com.izforge.izpack.installer.GUIInstaller.loadLook AndFeel(GUIInstaller.java:373)
    at com.izforge.izpack.installer.GUIInstaller.<init>(G UIInstaller.java:116)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:30
    at com.izforge.izpack.installer.Installer.main(Instal ler.java:62)
    
    • hb.Sara
      hb.Sara over 12 years
      i'm having the same problem, it works perfecly on console but when i use eclipse it throws the same exception i even put that code lines : Process proc_exporting =Runtime.getRuntime().exec("sudo export DISPLAY =:0.0"); still doesn't work
    • Admin
      Admin about 10 years
      None of the answers give the info needed to solve this problem when connecting to a console remotely via puTTY. Any answer that addresses SSH doesn't actually explain how to make it work. Anyone know of a question that addresses this?
  • user42155
    user42155 about 15 years
    Hi, thank you very much, the first one worked for me. Yes, I am starting it from a non-graphic terminal.
  • Paul Tomblin
    Paul Tomblin about 15 years
    It sounds like it wants to accesss the graphics display though. Be careful not to run it when the graphics display isn't available, or it belongs to some other userid.
  • KevinDTimm
    KevinDTimm about 15 years
    note that this worked because you are/were on the console. if you were on another terminal, you would have to have an X server running on the terminal and then set the environment to point to your machine (export DISPLAY='hostname of pauls terminal':0.0 for example)
  • Paul Tomblin
    Paul Tomblin about 15 years
    @kevindtimm, Good point - I'm going to incorporate @Mikeage's info about ssh -X into my answer.
  • Paul Tomblin
    Paul Tomblin about 15 years
    Oh right, Slackware. Is it still as barebones as it was when I last used it 10 years ago?
  • user3532201
    user3532201 about 15 years
    It still starts up by default in runlevel 3. Of course, if you tell it to start in runlevel 5, you'll get a pretty KDM login menu assuming you installed KDE.
  • Wichert Akkerman
    Wichert Akkerman over 12 years
    I would strongly recommend not to use "xhost +" since if effectively disables all security on your X server. ssh is smart enough to use xauth to setup X11 authentication automatically, so there should be no need to use xhost.
  • Wichert Akkerman
    Wichert Akkerman over 12 years
    In case you need to run an automated task that requires connecting to an X server you can look at xvfb, which creates a virtual X server. This is very useful for some batch tests or running tests.
  • jacktrades
    jacktrades over 11 years
    thanks! on CentOS and SSH (putty) used: export DISPLAY=:0
  • plamut
    plamut over 8 years
    Please include the essential information from the links in the answer itself, because they might go dead eventually, rendering the answer useless.
  • Elliot A.
    Elliot A. about 8 years
    This should be a comment, not a post. Just because you can't comment doesn't mean you should make a bad post.
  • Jeff.Lu
    Jeff.Lu almost 7 years
    On Windows, I use Putty+Nomachine to login my remote Linux VM. Within gnome GUI env, I start a terminal to ssh to another machine. I got the same error when start to run a GUI application in ssh session. Then "ssh -X" gets me out of the mess.
  • emfi
    emfi almost 7 years
    ah, that maybe explains, why i need to set this variable. because I use putty on localhost.
  • hfrog713
    hfrog713 almost 5 years
    I am on Windows using mobaXTerm and i was getting the same error. I updated the display variable as mentioned above and i am now getting the following message. Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. Is there a way to point to the XServer Display that is hosted by MobaXTerm and does anyone know how i get the information from Moba?
  • Tunahan
    Tunahan over 3 years
    It also works for connecting via MobaXTerm