Java service in headless environment

Situation

When running java service on Linux or Unix and getting the following error message:
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

Solution

Add the Java parameter -Djava.awt.headless=true to the script file that starts the application. 

-Djava.awt.headless=true