|
Question |
This technote explains how to use Java™ Abstract Window
Toolkit (AWT) on systems where the native graphics resource is not
available. |
|
|
|
Cause |
Sun Java bug : ID 4281163
Many environments, such as mainframe machines and dedicated servers, do
not support a display, keyboard, or mouse.
Java SDK 1.3. (all releases) does not allow server-side Java applications
(servlets) to use the full J2SE or J2EE™ API without a GUI environment
being present, because java.awt.Graphics methods are implemented in the
default JVM™ with native graphical functions. |
|
|
Answer |
There are two possible solutions.
- For releases prior to Java SDK 1.4,
Use another Java AWT which does not use native graphics resource (100%
Pure Java AWT), or you must run an X server.
- For Java SDK 1.4 and later,
Use the new headless AWT toolkit. This allows you to use the J2SE API in a
server-side Java application without a GUI environment.
Two new methods, are added to java.awt.GraphicsEnvironment to enable
Headless support:
public static boolean isHeadless()
public boolean isHeadlessInstance()
To run your environment with a headless implementation, specify the
following option at
the java command line:
-Djava.awt.headless=true |
|
|
|
|
|
|