Fake X11 display?

ashchristopher picture ashchristopher · Jan 30, 2009 · Viewed 14.5k times · Source

I have a Java program using AWT which I would like to run on a headless system. The display for the program does nothing other than display stats. When the program finishes, it exits. There is no user interaction on the display. The program creates an output file which I use in my build system.

Is there a way to get the Java program to run without an X11 display configured? Can I force Java to run the program without trying to display anything? I do not have access to the source code (it is just .jar file), so I can't make modifications to the source.

Any thoughts on how I could get this to work?

Answer

Charles Duffy picture Charles Duffy · Jan 30, 2009

The underlying question here is how to run Java applications without an X server; providing a "fake" X server is only one option. In Java 1.4 and up, you can do the following:

java -Djava.awt.headless=true

This allows applications which use AWT to run on headless systems even without an X server.