The java.awt.headless property (since JDK 1.4.2) can perhaps be used.
I quote:

Q: "...I find that when I run my application on Solaris or Linux it
needs an Xserver.(...)"

A: "There are two possible solutions. For releases prior to 1.4 you
can provide a "pseudo X-server" to emulate a display environment One
of these X-server emulators is Xvfb, available for download at www.x.org.