LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. (http://www.linuxquestions.org/questions/linux-general-1/cant-connect-to-x11-window-server-using-0-0-as-the-value-of-the-display-variable-178234/)

defa0009 05-05-2004 02:24 PM

Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
 
Hi, I am trying to run a JAVA class file and I keep getting the error below.
I have tried setting the display variable to:

export DISPLAY=localhost:0.0
export DISPLAY=ipaddress:0.0, but no luck.

I have also tried:

[root@ds26 rick]# xhost + localhost
xhost: unable to open display ""


Can anyone explain to me what could be the reason. And why does the
code even need this to run? The code works fine on a Windows machine.




Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using 'localhost:0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:81)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.Toolkit$2.run(Toolkit.java:748)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:739)
at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
at PicResizer.resizePic(PicResizer.java:41)
at PicResizer.<init>(PicResizer.java:30)
at PicResizer.main(PicResizer.java:92)

Tinkster 05-05-2004 03:07 PM

What distro, which version of X, .... ?
Xandros for instance have managed to bend
XFree in such fashion that the "normal" (the
things you tried) way of doing this doesn't
work anymore. This, how ever, works:

export DISPLAY=:0



Cheers,
Tink

defa0009 05-05-2004 04:03 PM

With a bit of digging I have found the solution. It seems that on LINUX and UNIX, Java products need access to the Java.AWT library to run graphic related methods.

Most versions of the Java.AWT library on UNIX require a functioning X server. The X server and the DISPLAY environment variable also needs to be correctly set. Here is what I did in case anybody else comes across this problem:

I installed the Xvfb rpm (X virtual frame buffer) and added these lines
to the /etc/profile file...

# Start the X virtual frame buffer (Xvfb)
if [ -f /usr/X11R6/bin/Xvfb ]; then
/usr/X11R6/bin/Xvfb :1 -screen 0 1024x768x16
fi

# Set the DISPLAY variable for the X virtual frame buffer (Xvfb)
export DISPLAY=localhost:1.0

Tinkster 05-05-2004 04:33 PM

You never mentioned the machine isn't
running X ;}


Cheers,
Tink

defa0009 05-05-2004 06:11 PM

Quote:

Originally posted by Tinkster
You never mentioned the machine isn't
running X ;}


Cheers,
Tink

I thought it was! :rolleyes:

PhilGee 09-18-2007 01:03 PM

export DISPLAY=:0 fixed the problem for me on RHEL 4.

rbestubbe 01-22-2009 05:29 AM

# xhost + worked for me

shweta.dba 11-11-2009 11:14 PM

Thanks.
 
Thanks . It works fine.


Regards
Shweta


Quote:

Originally Posted by Tinkster (Post 916925)
What distro, which version of X, .... ?
Xandros for instance have managed to bend
XFree in such fashion that the "normal" (the
things you tried) way of doing this doesn't
work anymore. This, how ever, works:

export DISPLAY=:0



Cheers,
Tink


kumarjyoti 10-25-2010 06:17 AM

Oracle 10g on CentOS 5.5 X11 error
 
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at java.awt.Window.init(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at oracle.ewt.popup.PopupFrame.<init>(Unknown Source)
at oracle.ewt.lwAWT.BufferedFrame.<init>(Unknown Source)
at oracle.sysman.oio.oioc.OiocOneClickInstaller.<init>(OiocOneClickInstaller.java:378)
at oracle.sysman.oio.oioc.OiocOneClickInstaller.main(OiocOneClickInstaller.java:2091)

kumarjyoti 10-25-2010 06:18 AM

X connection to localhost:11.0 broken (explicit kill or server shutdown)

dingo04 03-05-2011 07:56 AM

I remember I had such troubles because of permission problems, if X started from root and I try to start java from user, or vice verse. Try to start java from user that own this X DISPLAY socket, or find a way to change this socket access rights.

stress_junkie 03-05-2011 08:05 AM

Quote:

Originally Posted by defa0009 (Post 916816)
Hi, I am trying to run a JAVA class file and I keep getting the error below.
I have tried setting the display variable to:

export DISPLAY=localhost:0.0
export DISPLAY=ipaddress:0.0, but no luck.

I have also tried:

[root@ds26 rick]# xhost + localhost
xhost: unable to open display ""

If the Java program is running under your own account then the problem comes from DISPLAY being incorrectly defined. Try this:
Code:

export DISPLAY=":0.0"
If a different user account is running the program then the user account that "owns" the console must add permission for others to display on "their" X display. Try this:
Code:

xhost +local:all
If the program is being used on a different computer, say 192.168.3.5 then try this:
Code:

xhost +inet:192.168.3.5
I use these all the time on my main computer. I have three concurrent different users sharing the X display and I occasionally display something from another computer. I put the xhost commands in the .bashrc file of the user that owns the display so the xhost permissions are set automatically when I start a terminal window.

sahabcse 07-27-2011 07:12 AM

xhost +local:all is worked for me in centos virtual machine.

Thanks

swampf0x 01-20-2012 03:55 PM

I received the same errors as mentioned above...this is what worked for me (no quotes):

>export DISPLAY="IP Address":0.0


All times are GMT -5. The time now is 11:19 PM.