[英]java.awt.HeadlessException thrown from HeadlessGraphicsEnvironment.getDefaultScreenDevice
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服务器上进行一些图像处理(Debian with java version“1.6.0_12”),我从我的代码接收java.awt.HeadlessException:
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): 即使java.awt.headless设置为true(这个代码打印明显如此):
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? 不知道怎么解决这个问题?
When headless you don't have a screen device. 无头时,你没有屏幕设备。 The documentation is clear :
文档很清楚 :
Throws: HeadlessException - if isHeadless() returns true
抛出:HeadlessException - 如果isHeadless()返回true
Your code appears to be getting the default graphics device configuration on a machine that doesn't have a usable graphic device. 您的代码似乎是在没有可用图形设备的计算机上获取默认图形设备配置。 This doesn't make much sense, and is never going to work.
这没有多大意义,永远不会起作用。
If you could explain why you are trying to do this (on a headless machine) we might be able to offer an alternative. 如果您能解释为什么要尝试这样做(在无头机器上),我们可以提供替代方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.