Check for headless usage before attempting to use swing for errors.