Q: I am getting the following error when running your library jPDFPrint in our SunOS environment. How can I fix it?
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using 'localhost:0.0' as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:134) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62) at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:81) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.Toolkit$2.run(Toolkit.java:748) at java.security.AccessController.doPrivileged(Native Method) at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:739) |
A: Our libraries use Java Swing classes when printing or working with images for instance. When initialized, these classes need a windowing GUI environment.
If you are running in a console-only server, you will need to run in headless mode. This tells Java to simulate a graphical environment so the Swing classes can initialize properly.
To run in headless mode, add this argument to your classpath or server startup:
-Djava.awt.headless=true