Ensuring Java reading for text-based formats
This section describes how to read PDF, AFP, Word, HTML, PCL, and ASCII images in Java on UNIX-based operating systems when using the Imaging SDK for the Java platform.
To read PDF, AFP, Word, HTML, PCL, and ASCII images in Java on other UNIX-based operating systems, RasterMaster uses the Abstract Windowing Toolkit (AWT). In Solaris, calls into the java.awt
package will trigger a connection to the X11 Windowing environment.
Since servers often operate as headless, or without a display, there is no X11 environment. The result is a NoClassDefFound
error, similar to the following:
java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:115)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment( GraphicsEnvironment.java:53)
at
java.awt.image.BufferedImage.createGraphics (BufferedImage.java:1006)
Depending on the JDK version, the following are solutions to this problem:
JDK 1.4 or greater
In JDK 1.4 and above, instruct the JDK to operate as a headless server, by setting a java run time option as follows:
java -Djava.awt.headless=true
In many cases, setting this option involves modifying the start-up script to your application server (often JAVA_OPTIONS
or JAVA_OPTS
).
Have questions, corrections, or concerns about this topic? Please let us know!