JDK-4038225 : Java application stops if DISPLAY not set
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1,1.1.3,1.1.6,1.2.2
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1,solaris_2.6,solaris_7
  • CPU: sparc
  • Submitted: 1997-03-11
  • Updated: 2000-06-03
  • Resolved: 2000-06-03
Related Reports
Duplicate :  
Duplicate :  
Description

Name: mc57594			Date: 03/11/97


Any Java application that references or imports a java class which
may have references to the AWT will stop working if the X DISPLAY
variable is not set. The java application should not stop working
simply because a class that has AWT components is imported. I
have developed a package that renders IDEF0 process models on a 
canvas. It turns out that this package is also useful for converting
IDEF0 models to other data formats. When attempting to print ASCII
data formats to the System.out stream and never intending to start an
windowing application, the java application simply stops because the X DISPLAY is
not set. In order to make classes useful, they should be re-usable.
Classes should not be limited to reuse as windowing classes or text
only classes. I should be able to use them for any purpose that I see
as necessary. Because of this AWT bug, I can only use my classes that
have windowing components as foreground windowing applications or applets.
These classes would be useful for background processing and/or CGI
programming in some instances, so there is a legitimate need for classes
to be able to operate both in a windowing mode and silently on the
command line. Because I have a class that knows how to draw itself
doesn't mean that the class has a limited scope of operation or usefulness.


company - Lockheed Martin C2 Integration Systems , email - ###@###.###
======================================================================

Comments
EVALUATION 6/3/2000 kevin.ryan@eng -- The issue is that an X server is required. This is covered in other bugs, and particularly in 4281163, which (as of today) has 169 Bug Parade votes. Based on the support for the latter bug #, am duping this bug to # 4281163.
11-06-2004

WORK AROUND Name: mc57594 Date: 03/11/97 ====================================================================== tim.bell@Eng 1998-11-06 (company - Space Telescope Science Institute , email - ###@###.###) One user reports: I got around the problem by passing in DISPLAY as a property, (easy since we start our application from a shell script), then calling some code like the following. This is for example only... YOU must modify to suit your application: static public boolean display_ok() { // See if the local display is accessed if ( System.getProperty("DISPLAY").equals(":0.0")) return true; // Check overall syntax StringTokenizer display = new StringTokenizer(System.getProperty("DISPLAY"),":"); if ( display.countTokens() != 2 ) { System.out.println("DISPLAY variable formed incorrectly: "+ System.getProperty("DISPLAY")); System.out.println("Correct format is: " + "<Hostname>:<keyboard>.<mouse>"); System.out.println("i.e. foo:0.0"); return false; } // See if host is valid String host = display.nextToken(); InetAddress address; try { address = InetAddress.getByName(host); } catch ( Exception e ) { System.out.println("Could not find host:"+host); return false; } // Check syntax of keyboard and mouse StringTokenizer test_kyb_mouse = new StringTokenizer(display.nextToken(),"."); if ( test_kyb_mouse.countTokens() != 2 ) { System.out.println("DISPLAY variable formed incorrectly"); System.out.println("The Keyboard and Mouse portion is incorrect"); System.out.println("Correct format is: " + "<Hostname>:<keyboard>.<mouse>"); System.out.println("i.e. "+host+":0.0"); return false; } // See if the server is running String port = System.getProperty("xport"); if ( port == null ) port = "6000"; int port_no; try { port_no = Integer.parseInt(port); } catch ( Exception e ) { System.out.println("The command line option must" + "be an integer number"); System.out.println("i.e. -xport 6000"); return false; } Socket socket; try { socket = new Socket(address, port_no); } catch (Exception e) { System.out.println("No X-Server is running on host, "+ host+", port, "+ port+"."); return false; } // Test for X Server permission try { Toolkit tk = Toolkit.getDefaultToolkit(); } catch (Error e) { System.out.println("X-Server access is denied on host, "+host); return false; } // release the test socket try { socket.close(); } catch ( Exception e ) { } socket = null; return true; } The only hitch is the ugly Xlib messages that are printed when an X-server denies access. Xlib: connection to "abc:0.0" refused by server Xlib: Client is not authorized to connect to Server X-Server access is denied on host, abc
11-06-2004

PUBLIC COMMENTS 6/3/2000 kevin.ryan@eng -- duping this bug to # 4281163, since it has 169 Bug Parade votes
10-06-2004