swing not getting initialized when the DISPLAY is not set

I have a batch programme which will load the Spreadsheet into database..

When the DISPLAY is set and X11 window server is running, there is no issue in reading the spreadsheet and loading into database without lauching UI.

But if the display is not set, then there is an issue... Any ideas over this ?? Why does a batch programme requires DISPLAY and X11 window server to be set when there is no need of UI to launch....

Code pasted below :

24  public class Spreadsheet extends com.f1j.swing.JBook
25  \{
26      private int failedSheetNum = 0;
27
28      public Spreadsheet\(\)
29      \{
30         super\(\);
31         setup\(\);
32      \}

Exception is thrown at line 30 :

Exception in thread "main" Logging starts at 15/7/2009 10:52:16
Loading the XML...
This might take a few seconds.Please wait...
Loading the Mapping template...
Loading the input data file...
This might take a few seconds.Please wait...
java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at <Unloaded Method>
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName0(Compiled Code)
at java.lang.Class.forName(Compiled Code)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:56)
at <Unloaded Method>
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName0(Compiled Code)
at java.lang.Class.forName(Compiled Code)
at java.awt.Toolkit$2.run(Toolkit.java:492)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:485)
at java.awt.SystemColor.updateSystemColors(SystemColor.java:339)
at <Unloaded Method>
at java.awt.Insets.initIDs(Compiled Code)
at com.f1j.swing.JBook.<init>(DashoA8533)
at com.f1j.swing.JBook.<init>(DashoA8533)
at gdm.ssl.Spreadsheet.<init>(Spreadsheet.java:30)

Try to see if headless mode works for you:

Using Headless Mode in the Java SE Platform

headless mode does not work for me.. I tried it using JVM option -Djava.awt.headless=true

Wondering, is there any similar option for swings only? (Formula one has 2 components one is awt and other one is swing)

I need it urgently the solution... Any ideas over this folks?