Cannot create headless window: mode must be non-null

I am creating an application to run in a servlet which renders frames for display on a webpage. I am able to create a headless window only at the full size of the screen.



The lines:



display = DisplaySystem.getDisplaySystem("LWJGL");

display.createWindow(640, 480, 24, 50, false);



produce the error:



java.lang.Error: Cannot create headless window: mode must be non-null

at com.jme.system.lwjgl.LWJGLDisplaySystem.initHeadlessDisplay(Unknown Source)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createHeadlessWindow(Unknown Source)

at scratch.Headless.initSystem(Headless.java:142)

at com.jme.app.BaseHeadlessApp.start(Unknown Source)

at scratch.Headless.main(Headless.java:34)

Caused by: java.lang.NullPointerException: mode must be non-null

at org.lwjgl.opengl.Display.setDisplayMode(Display.java:215)

… 5 more



It seems that the only mode available is the one with the full size of the screen… with which I have been able to create a headless window and output it to a PNG for development purposes. I cant remember where it was now nor find it but I stuck a foreach in the class which searches for the closest mode and the Array of modes it was choosing from only contained the 2880x1220 mode of my screen. Hmm.



Here is my code in its entirety, which if run produces a black PNG of the specified dimension on my desktop.



public class Scratch extends SimpleGame {
   
   public static void main(String[] args) {
      DisplaySystem display = DisplaySystem.getDisplaySystem("LWJGL");

      display.createHeadlessWindow(2880, 1200, 24); //works
//      display.createWindow(640, 480, 32, 50, false); //exception
      
      renderer.takeScreenShot("/home/jd204/Desktop/monkey");
   }

   @Override
   protected void simpleInitGame() {
      // TODO Auto-generated method stub
   }



As a side issue, I cannot find anywhere a basic example of how to use this engine to just render something... there are dozens of abstract 'SimpleX' classes and 'BaseX' etc, I just want to plot a static 3D scene and fire it to a buffer!

Any help would be much appreciated.

Best
James