Changeset 121c8172


Ignore:
Timestamp:
Feb 4, 2011 5:09:13 PM (9 years ago)
Author:
mathiasdm <mathiasdm@…>
Branches:
master
Children:
6b852af
Parents:
c979d65
Message:

Fix for headless.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/desktopgui/src/net/i2p/desktopgui/Main.java

    rc979d65 r121c8172  
    88import javax.swing.UIManager;
    99import javax.swing.UnsupportedLookAndFeelException;
     10import java.awt.GraphicsEnvironment;
    1011
    1112import net.i2p.I2PAppContext;
     
    5556     */
    5657    public static void beginStartup(String[] args) {
    57         System.setProperty("java.awt.headless", "false");
     58        boolean wasHeadless = Boolean.valueOf(System.getProperty("java.awt.headless")).booleanValue();
     59        if(wasHeadless) {
     60            System.setProperty("java.awt.headless", "false");
     61        }
     62        boolean headless_check = true;
     63        try {
     64            // X permissions error is a java.lang.InternalError (a Throwable)
     65            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     66            headless_check = ge.isHeadlessInstance();
     67        } catch (Throwable t) {}
     68        if (wasHeadless)
     69            System.setProperty("java.awt.headless", "true");
     70        if (headless_check) {
     71            return;
     72        }
    5873        try {
    5974            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     
    88103           
    89104        });
     105
    90106    }
    91107   
Note: See TracChangeset for help on using the changeset viewer.