Server Based JavaFX Initialization
To run JavaFX on the server, you must either:
These are the only ways that the JavaFX runtime system is initialized in JavaFX 2 so that you can use it.
Using a JFXPanel is probably a little less efficient than using a JavaFX application.
The following discusses JavaFX system initialization in the StackOverflow question: JavaFX 2.1: Toolkit not initialized .
JavaFX is a single-threaded system
You can create most JavaFX components in any thread. However, to render components in a scene, you must do work on the JavaFX application thread. This means that if you have a multi-threaded server process that most servers run on and you want to generate multiple diagrams, you will need to execute a single flow of diagram rendering requests using concurrency restrictions.
Then, the server handler stream can be used by ImageIO to convert the AWT image to the output stream in png format. You can take the resulting stream and Base64 encode it and return the base 64-encoded stream to the server in response to calling the request for the original image request.
Ensure a graceful shutdown
You will want to call Platform.setImplicitExit (false) when your server starts and registers a stop hook or ServletContextListener , which controls when the servlet is destroyed, so you also call the .exit () platform to disable the JavaFX system. If you do not, it is likely that your server will not be able to shut down because the JavaFX application thread will continue to work, waiting for work.
JavaFX 2.2 is not really certified to work on a headless server
Swing applications can run silently using the java.awt.headless system property. I do not know about a similar property for JavaFX, although there may be one, and if that were possible, you could find out what it is by asking the openjfx-dev mailing list .
JavaFX is primarily designed as a client graphics toolkit. Although you can make it work and work satisfactorily for your application on the server, for this you may need to make sure that the server is not configured as a headless server and that it has an appropriate accelerator graphics card that provides reasonable loading performance.
You can request official headless mode support for JavaFX bug tracking .