LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-05-2004, 01:24 PM   #1
defa0009
Member
 
Registered: Jun 2003
Posts: 185

Rep: Reputation: 31
Question 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)

Last edited by defa0009; 05-05-2004 at 01:27 PM.
 
Old 05-05-2004, 02:07 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 05-05-2004, 03:03 PM   #3
defa0009
Member
 
Registered: Jun 2003
Posts: 185

Original Poster
Rep: Reputation: 31
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
 
Old 05-05-2004, 03:33 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
You never mentioned the machine isn't
running X ;}


Cheers,
Tink
 
Old 05-05-2004, 05:11 PM   #5
defa0009
Member
 
Registered: Jun 2003
Posts: 185

Original Poster
Rep: Reputation: 31
Quote:
Originally posted by Tinkster
You never mentioned the machine isn't
running X ;}


Cheers,
Tink
I thought it was!
 
Old 09-18-2007, 12:03 PM   #6
PhilGee
LQ Newbie
 
Registered: Aug 2005
Posts: 1

Rep: Reputation: 0
export DISPLAY=:0 fixed the problem for me on RHEL 4.
 
Old 01-22-2009, 04:29 AM   #7
rbestubbe
LQ Newbie
 
Registered: May 2008
Posts: 5

Rep: Reputation: 0
# xhost + worked for me
 
Old 11-11-2009, 10:14 PM   #8
shweta.dba
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
Thanks.

Thanks . It works fine.


Regards
Shweta


Quote:
Originally Posted by Tinkster View Post
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
 
Old 10-25-2010, 05:17 AM   #9
kumarjyoti
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
Unhappy 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)
 
Old 10-25-2010, 05:18 AM   #10
kumarjyoti
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
X connection to localhost:11.0 broken (explicit kill or server shutdown)
 
Old 03-05-2011, 06:56 AM   #11
dingo04
LQ Newbie
 
Registered: Mar 2011
Posts: 1

Rep: Reputation: 0
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.
 
Old 03-05-2011, 07:05 AM   #12
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by defa0009 View Post
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.

Last edited by stress_junkie; 03-05-2011 at 07:16 AM.
 
Old 07-27-2011, 06:12 AM   #13
sahabcse
LQ Newbie
 
Registered: Mar 2009
Location: colachel
Posts: 7

Rep: Reputation: 0
Thumbs up

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

Thanks
 
Old 01-20-2012, 02:55 PM   #14
swampf0x
Member
 
Registered: Feb 2011
Location: South Carolina
Distribution: SLES10 SP4
Posts: 30

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

>export DISPLAY="IP Address":0.0
 
Old 07-21-2021, 01:39 AM   #15
harithap
LQ Newbie
 
Registered: Jul 2021
Posts: 1

Rep: Reputation: Disabled
Hello,

I'm getting this error, when I submit a test in linux machine. the linux machine is picked randomly. So I will not know the ip address.
Request your help to get it resolved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot connect to X11 window server using ":).0" as DISPLAY variable cclack Linux - Newbie 4 09-06-2007 09:32 PM
Can't connect to X11 window server suresheva31 Linux - General 0 10-19-2004 02:17 PM
Can't connect to X11 window server Checking operating system version: must be redha pmarino Linux - General 2 09-20-2004 04:18 PM
get "can't connect to X11 window server using :0.0" andytorn Linux - Newbie 3 05-09-2004 06:46 PM
RedHat Linux 7.3 and X11 window server?? kiwiMike Linux - Software 0 02-21-2004 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration