Allan,

if the X server is running while tomcat is running - i.e. your server 
has a GUI interface, then tomcat should be able to use it, as DISPLAY 
defaults to 127.0.0.1:0 and connections from Xclients on localhost 
should be accepted.

If X is on your machine, but you aren't actually running the X Server, 
then AWT won't be able to get a context to draw with.

You have several options.

1) Just run X. Start up a minimal GUI on your machine, and leave it. 
This can eat resources, however.

2) Use Xvfb, shipped with XFree86 3.3.5?+ and 4.x.x THis is a 'Virtual 
framebuffer' that gives you an X Server you can use with AWT without any 
actual on-screen display. I have used this for java apps on a headless 
SGI machine running IRIX, and it worked well. BE aware that the 
bit-depth you set the display to will affect the results of your graphic 
drawing operations - i.e. my GIFs have greadient fills, and i notice 
major 'banding' if i use a 16bit display as compared to a 32bit display.

3) Use VNC Server. This gives you an X server too, but i think Xvfb 
would be preferable.

4) There are AWT libraries floating around that do not require X. I 
forget who supplies these.

5) Use another machine's X Server. I wouldn't recommend this for 
production use (since graphic operations will require slow network 
operations) but it is a nifty demonstration of why X is cool. set 
DISPLAY to remotemachine:0 and on the remote machine, type 'xhost 
+yourmachine' from a xterm or something. xhost is the command that adds 
permission for machines to access the X server.

in cases 2 and 3, you would need to, as part of your tomcat start 
script, or just sometime before you start tomcat, to start Xvfb with a 
display number of say, 2, and then set an environment variable to point 
to it e.g. export DISPLAY=:2

If, for some reason, you are actually having problems connecting to an 
already running display, make sure you have a DISPLAY environment 
variable set in whatever shell tomcat is running in.

This should get you up and running.

-Pete

> Hi folks,
> I need to use features of the AWT implementation for
> creating off-screen
> images from a servlet.
> Using AWT requires the use of the host machine's
> graphic system which in my
> case is X11 as I am running RH Linux 6.2.
> I would like to know how to grant the servlet
> container access to the X11
> server.
> 
> Allan Kamau.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/



Reply via email to