从HeadlessGraphicsEnvironment.getDefaultScreenDevice java.awt.HeadlessException异常抛出 [英] java.awt.HeadlessException thrown from HeadlessGraphicsEnvironment.getDefaultScreenDevice
问题描述
我需要做一个Java服务器上的一些图像处理(Debian中的Java版本1.6.0_12),
而我从我的code接收java.awt.HeadlessException异常:
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)
当java.awt.headless设置为true
即使(这个code印花那么明显的话):
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");
}
这是code抛出异常:
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?
推荐答案
在无头没有屏幕设备。在<一个href=\"http://download.oracle.com/javase/6/docs/api/java/awt/GraphicsEnvironment.html#getDefaultScreenDevice%28%29\"相对=nofollow>文档清晰:
When headless you don't have a screen device. The documentation is clear:
抛出:
HeadlessException的 - 如果isHeadless()返回true
Throws: HeadlessException - if isHeadless() returns true
这篇关于从HeadlessGraphicsEnvironment.getDefaultScreenDevice java.awt.HeadlessException异常抛出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!