Running Chart FX for Java on a headless server

A headless server is defined as a server running without graphical interfaces. Chart FX for Java utilizes these interfaces in order to generate the chart files, therefore, exceptions will be thrown if access is not available during chart generation. The exceptions thrown will include references to the java.awt.AHGraphicsEnvironment or java.awt.GraphicsEnvironment classes.

In order to avoid the exception, some configuration is necesary in order to run Chart FX for Java in a Headless Server configuration. For more information please go to http://java.sun.com/products/java-media/2D/forDevelopers/java2dfaq.html#xvfb

JDK 1.4

When running JDK 1.4 or later in a Headless Server configuration, you must ensure that the system property java.awt.headless is set to true. With this setting, images are rendered using the standard Java class javax.imageio.ImageIO.

To specify the headless environment, you need to add the following line to the application server settings:


-Djava.awt.headless=true

JDK 1.3

With JDK 1.3 or earlier, the javax.imageio.ImageIO class cannot be used because it does not exist. In order to run Chart FX for Java in a headless server configuration using these JDK’s, you must utilize a "pseudo X-server" to emulate a display environment One of these X-server emulators is Xvfb, available for download at www.x.org. Xvfb is included in most OS packages.

You will need to execute two commands in order to enable Xvfb on your server. Below is an example of this for a linux server running Tomcat with JDK 1.3:


[root@linux bin]# Xvfb :0 -screen 0 1024x786x16 &
[root@linux bin]# export DISPLAY=:0