Java3D headless mode is a way how to tell Java that there is not physical screen device and that there is no graphics acceleration. Headless model could be set in this way:
java -Djava.awt.headless=true
In headless mode some object can't be instantiated, especially UI related objects from java.awt package like Button. More about headless could be found at http://www.oracle.com/technetwork/articles/javase/headless-136834.html.
Java3D application usually build 3D model and that draw it to Canvas3D. Sometimes server need to generate some images which are using Canvas3D. Sadly in headless mode it's not possible. Because it's not possible to instantiate Canvas3D. Lets look at following code:
public void testSimple() throws Exception { System.setProperty("java.awt.headless", "true"); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template); Canvas3D canvas3d = new Canvas3D(config, true); }
In headless mode GraphicsEnvironment.getLocalGraphicsEnvironment()
return instance of HeadlessGraphicsEnvironment
. Method HeadlessGraphicsEnvironment is implemented in following way:
public GraphicsDevice getDefaultScreenDevice() throws HeadlessException { throw new HeadlessException(); }
So it always throw HeadlessException. Because of that it seems that Java3D can't be used with enabled headless mode.
No comments:
Post a Comment