I was trying to run the following code in UNIX:
public class FontTest
public static void main(String args)
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font fa = ge.getAllFonts();
for (int i=0; i<fa.length; i++)
But I got 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
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at <Unloaded Method>
at java.lang.Class.forName0(Native Method)
at FontTest.main(Compiled Code)
I am new to Java on UNIX. Please tell mw what is wrong with the system. Do I need to install something on this system?
Thanks in advance
The error you are getting is because there is no XServer started on the unix machine. AWT tries to get the defaut fonts (colors, etc.) from the underlying windowing system, which in your case is not started. However if you want your test to work you should tell the JVM that is running in a non-window environment by setting the system property java.awt.headless=true.
Best regards, Mircea
The msg about DISPLAY variable points to something other than the previous user suggested. If that suggestion did not help, try this:
If the program is on unix1 box and you did a telnet/ssh from win1 box,
then you need to set the DISPLAY variable to your box. A best way to test this is to open a command window xterm etc after you set the display variable.
The same holds even if your box (win1) is a windows or unix.