Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4378487
Votes 0
Synopsis Need method to determine availability of windowing system
Category java:classes_awt
Reported Against 1.2.2
Release Fixed
State 11-Closed, duplicate of 4281163, request for enhancement
Priority: 4-Low
Related Bugs 4281163
Submit Date 12-OCT-2000
Description




java version "1.2.2"
Classic VM (build 1.2.2_006, green threads, nojit)

On some platforms and in some situations the JVM may not be able to create and
display graphical components due to the absence of a windowing system (i.e.
Windows / X). In particular, a Linux system may not have X installed, or the
current user may be connecting remotely via telnet etc.

The awt should provide a means of determining whether or not this is the case.
I am developing an application which runs both as a text-mode app and with a
graphical UI and I want to be able to determine which UI to use on a particular
occasion.

Ideally there should be a method such as Toolkit.isWindowingSystemAvailable(),
but if that is not possible, there should at least be a descriptive exception
(i.e. NOT InternalError) thrown if this problem is encountered. Currently the
following code, when run during a telnet session to a Linux (JDK 1.2.2) box,
produces the error message:

"Exception in thread "main" java.lang.InternalError: Can't connect to X11
window server using ':0.0' as the value of the DISPLAY variable."


import javax.swing.*;

public class GTest
{
    public static void main(String[] args)
    {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.show();
    }
}
(Review ID: 110732) 
======================================================================
Work Around




Put the calls which create the graphical UI inside a try block and catch
java.lang.InternalError.
======================================================================
Evaluation
N/A
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang