title: JavaFX screencapture headless exception on OSX
body: <p>I'm converting my old java app from swing to javafx and I'm running into a problem.</p>
  
  <p>I'm using the following code to capture screenshots:</p>
  
  <pre><code> public ScreenCapper() {
      ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      gs = ge.getScreenDevices();
  
      try {
          robot = new Robot(gs[gs.length-1]);
      } catch (AWTException e) {
          LOGGER.getInstance().ERROR("Error creating screenshot robot instance!");
      }
  }
  
  public Color capture() {
      Rectangle bounds;
  
      mode = gs[0].getDisplayMode();
      bounds = new Rectangle(0, 0, mode.getWidth(), mode.getHeight());
      //......
  }
  </code></pre>
  
  <p>This works fine when running the application under Windows. However when running under OSX in get the following exception:</p>
  
  <pre><code>Exception in Application start method
  Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
  at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
  at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
  at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
  at java.lang.Thread.run(Thread.java:722)
  Caused by: java.awt.HeadlessException
  at sun.java2d.HeadlessGraphicsEnvironment.getScreenDevices(HeadlessGraphicsEnvironment.java:72)
  at be.beeles_place.roggbiv.utils.ScreenCapper.&lt;init&gt;(ScreenCapper.java:33)
  at be.beeles_place.roggbiv.modes.AverageColorMode.start(AverageColorMode.java:31)
  at be.beeles_place.roggbiv.modes.ColorModeContext.startCurrentColorMode(ColorModeContext.java:28)
  at be.beeles_place.roggbiv.controller.RoggbivController.&lt;init&gt;(RoggbivController.java:42)
  at be.beeles_place.roggbiv.RoggbivMain.start(RoggbivMain.java:67)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
  </code></pre>
  
  <p>This I think has todo with javafx appearently running is headless mode on OSX, as the following debug warnings suggest:</p>
  
  <pre><code>013-03-10 10:44:03.795 java[1912:5903] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
  2013-03-10 10:44:05.472 java[1912:707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
  </code></pre>
  
  <p>Is there any way to get this to work? Or another way to capture screenshots that does not conflict with OSX?</p>
  
  <p>full code @ <a href="https://github.com/beele/Roggbiv">https://github.com/beele/Roggbiv</a></p>