src/share/classes/java/awt/GraphicsEnvironment.java

Print this page




 153             "\nNo X11 DISPLAY variable was set, " +
 154             "but this program performed an operation which requires it.";
 155     }
 156 
 157     /**
 158      * @return the value of the property "java.awt.headless"
 159      * @since 1.4
 160      */
 161     private static boolean getHeadlessProperty() {
 162         if (headless == null) {
 163             java.security.AccessController.doPrivileged(
 164             new java.security.PrivilegedAction() {
 165                 public Object run() {
 166                     String nm = System.getProperty("java.awt.headless");
 167 
 168                     if (nm == null) {
 169                         /* No need to ask for DISPLAY when run in a browser */
 170                         if (System.getProperty("javaplugin.version") != null) {
 171                             headless = defaultHeadless = Boolean.FALSE;
 172                         } else {





 173                             String osName = System.getProperty("os.name");
 174                             headless = defaultHeadless =
 175                                 Boolean.valueOf(("Linux".equals(osName) ||
 176                                                 "SunOS".equals(osName) ||
 177                                                 "FreeBSD".equals(osName) ||
 178                                                 "NetBSD".equals(osName) ||
 179                                                 "OpenBSD".equals(osName)) &&
 180                                                 (System.getenv("DISPLAY") == null));

 181                         }
 182                     } else if (nm.equals("true")) {
 183                         headless = Boolean.TRUE;
 184                     } else {
 185                         headless = Boolean.FALSE;
 186                     }
 187                     return null;
 188                 }
 189                 }
 190             );
 191         }
 192         return headless.booleanValue();
 193     }
 194 
 195     /**
 196      * Check for headless state and throw HeadlessException if headless
 197      * @since 1.4
 198      */
 199     static void checkHeadless() throws HeadlessException {
 200         if (isHeadless()) {




 153             "\nNo X11 DISPLAY variable was set, " +
 154             "but this program performed an operation which requires it.";
 155     }
 156 
 157     /**
 158      * @return the value of the property "java.awt.headless"
 159      * @since 1.4
 160      */
 161     private static boolean getHeadlessProperty() {
 162         if (headless == null) {
 163             java.security.AccessController.doPrivileged(
 164             new java.security.PrivilegedAction() {
 165                 public Object run() {
 166                     String nm = System.getProperty("java.awt.headless");
 167 
 168                     if (nm == null) {
 169                         /* No need to ask for DISPLAY when run in a browser */
 170                         if (System.getProperty("javaplugin.version") != null) {
 171                             headless = defaultHeadless = Boolean.FALSE;
 172                         } else {
 173                             if ("sun.awt.HeadlessGraphicsEnvironment".equals(
 174                                     System.getProperty("java.awt.graphicsenv")))
 175                             {
 176                                 headless = defaultHeadless = Boolean.TRUE;
 177                             } else {
 178                                 String osName = System.getProperty("os.name");
 179                                 headless = defaultHeadless =
 180                                     Boolean.valueOf(("Linux".equals(osName) ||
 181                                                      "SunOS".equals(osName) ||
 182                                                      "FreeBSD".equals(osName) ||
 183                                                      "NetBSD".equals(osName) ||
 184                                                      "OpenBSD".equals(osName)) &&
 185                                                      (System.getenv("DISPLAY") == null));
 186                             }
 187                         }
 188                     } else if (nm.equals("true")) {
 189                         headless = Boolean.TRUE;
 190                     } else {
 191                         headless = Boolean.FALSE;
 192                     }
 193                     return null;
 194                 }
 195                 }
 196             );
 197         }
 198         return headless.booleanValue();
 199     }
 200 
 201     /**
 202      * Check for headless state and throw HeadlessException if headless
 203      * @since 1.4
 204      */
 205     static void checkHeadless() throws HeadlessException {
 206         if (isHeadless()) {