JDK-4378487 : Need method to determine availability of windowing system
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2000-10-12
  • Updated: 2000-10-13
  • Resolved: 2000-10-13
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 10/11/2000


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) 
======================================================================

Comments
WORK AROUND Name: rmT116609 Date: 10/11/2000 Put the calls which create the graphical UI inside a try block and catch java.lang.InternalError. ======================================================================
11-06-2004