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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
05-05-2004, 01:24 PM
|
#1
|
Member
Registered: Jun 2003
Posts: 185
Rep:
|
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.
|
|
|
05-05-2004, 02:07 PM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
05-05-2004, 03:03 PM
|
#3
|
Member
Registered: Jun 2003
Posts: 185
Original Poster
Rep:
|
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
|
|
|
05-05-2004, 03:33 PM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
You never mentioned the machine isn't
running X ;}
Cheers,
Tink
|
|
|
05-05-2004, 05:11 PM
|
#5
|
Member
Registered: Jun 2003
Posts: 185
Original Poster
Rep:
|
Quote:
Originally posted by Tinkster
You never mentioned the machine isn't
running X ;}
Cheers,
Tink
|
I thought it was! 
|
|
|
09-18-2007, 12:03 PM
|
#6
|
LQ Newbie
Registered: Aug 2005
Posts: 1
Rep:
|
export DISPLAY=:0 fixed the problem for me on RHEL 4.
|
|
|
01-22-2009, 04:29 AM
|
#7
|
LQ Newbie
Registered: May 2008
Posts: 5
Rep:
|
# xhost + worked for me
|
|
|
11-11-2009, 10:14 PM
|
#8
|
LQ Newbie
Registered: Feb 2009
Posts: 3
Rep:
|
Thanks.
Thanks . It works fine.
Regards
Shweta
Quote:
Originally Posted by Tinkster
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
|
|
|
|
10-25-2010, 05:17 AM
|
#9
|
LQ Newbie
Registered: Oct 2010
Posts: 2
Rep:
|
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)
|
|
|
10-25-2010, 05:18 AM
|
#10
|
LQ Newbie
Registered: Oct 2010
Posts: 2
Rep:
|
X connection to localhost:11.0 broken (explicit kill or server shutdown)
|
|
|
03-05-2011, 06:56 AM
|
#11
|
LQ Newbie
Registered: Mar 2011
Posts: 1
Rep:
|
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.
|
|
|
03-05-2011, 07:05 AM
|
#12
|
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873
|
Quote:
Originally Posted by defa0009
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:
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.
|
|
|
07-27-2011, 06:12 AM
|
#13
|
LQ Newbie
Registered: Mar 2009
Location: colachel
Posts: 7
Rep:
|
xhost +local:all is worked for me in centos virtual machine.
Thanks
|
|
|
01-20-2012, 02:55 PM
|
#14
|
Member
Registered: Feb 2011
Location: South Carolina
Distribution: SLES10 SP4
Posts: 30
Rep:
|
I received the same errors as mentioned above...this is what worked for me (no quotes):
>export DISPLAY="IP Address":0.0
|
|
|
07-21-2021, 01:39 AM
|
#15
|
LQ Newbie
Registered: Jul 2021
Posts: 1
Rep: 
|
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.
|
|
|
All times are GMT -5. The time now is 12:35 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|