• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't connect to X11 window

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I have written a small swing program which is working perfectly in Windows.When i try to run the same program in unix its giving the following exception.
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window
server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:5
4)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:115)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi
ronment.java:53)
at java.awt.Window.<init>(Window.java:183)
at java.awt.Frame.<init>(Frame.java:310)
at java.awt.Frame.<init>(Frame.java:289)
at javax.swing.JFrame.<init>(JFrame.java:167)
at LabelDemo.<init>(LabelDemo.java:9)
at LabelDemo.main(LabelDemo.java:45)
Can you please help me.
i am thinking some problem with look and feel but not sure.
Plase help me.
Here is my code
import java.awt.*;
import javax.swing.*;
class LabelDemo
extends JFrame
{
public LabelDemo()
{
super("JLabel Demo");
setSize(600, 100);
JPanel content = (JPanel) getContentPane();
content.setLayout(new GridLayout(1, 4, 4, 4));
JLabel label = new JLabel();
label.setText("JLabel");
label.setBackground(Color.white);
content.add(label);
label = new JLabel("JLabel",
SwingConstants.CENTER);
label.setOpaque(true);
label.setBackground(Color.white);
content.add(label);
label = new JLabel("JLabel");
label.setFont(new Font("Helvetica", Font.BOLD, 18));
label.setOpaque(true);
label.setBackground(Color.white);
content.add(label);
ImageIcon image = new ImageIcon("flight.gif");
label = new JLabel("JLabel", image,
SwingConstants.RIGHT);
label.setVerticalTextPosition(SwingConstants.TOP);
label.setOpaque(true);
label.setBackground(Color.white);
content.add(label);
setVisible(true);
}
public static void main(String args[])
{
new LabelDemo();
}
}
Regards
Kiran
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is just a common X11 application problem, not a Java thing, really. We can't help you debug it without knowing a bit more about your environment. It actually would be much easier for someone at your end who knew something about X to help you figure out what's going on.
One possibility: you've use "telnet" or similar to connect to a remote UNIX server from your Windows box, and are running the app on the server, but you don't have an X server on your desktop machine for it to display to.
 
Kiran Baratam
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:

One possibility: you've use "telnet" or similar to connect to a remote UNIX server from your Windows box, and are running the app on the server, but you don't have an X server on your desktop machine for it to display to.


Hi Ernest
Yes i am connecting to unix box through telnet and tryimng to execute.
my normal javaprogram is working fine like this only.
Kiran
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, then.
You need a program called an "X server" to run on your desktop machine. The way that X/Windows works is that a program (a Java program, or any graphical program) sends commands to the X server to tell it to display windows on its behalf. If you don't have an X server on your local machine, then the program will fail and won't be able to display a GUI.
There are commercial X servers for Windows like eXceed and Hummingbird, and there is at least one free one (the Cygwin port of XFree86, see http://cygwin.com/xfree/ .)
Alternatively, instead of getting an X server, you could use VNC; see http://www.tightvnc.com/ for one version of this open-source software.
Before you deccide that X/Windows sucks, think about how, from the UNIX machine, you would run the Windows version of your program (actually, VNC would let you do this, too.)
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic