java.awt.HeadlessException thrown from HeadlessGraphicsEnvironment.getDefaultScreenDevice

Posted by Omry on Stack Overflow See other posts from Stack Overflow or by Omry
Published on 2010-12-26T15:45:28Z Indexed on 2010/12/26 15:54 UTC
Read the original article Hit count: 278

Filed under:
|
|

I need to do some image processing on a java server (Debian with java version "1.6.0_12"), and I am receiving java.awt.HeadlessException from my code:

java.awt.HeadlessException
    at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:64)
    at WaxOn.getDefaultConfiguration(WaxOn.java:341)

Even when java.awt.headless is set to true (as evident by this code printing so):

if (!java.awt.GraphicsEnvironment.isHeadless())
{
    logger.warn("Headless mode is not enabled");
}
else
{
    logger.info("Headless mode");
}

This is the code that throws the exception:

public static GraphicsConfiguration getDefaultConfiguration()
{
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();
}

Any idea how to solve this?

© Stack Overflow or respective owner

Related posts about java

Related posts about awt