PDA

View Full Version : embedded graphics in JSP / servlet pages


lilpup
06-22-2005, 04:49 AM
I just went through the process of setting up my VPS to allow for dynamic creation of images through Java code in Tomcat and thought this information might be useful to someone else here in the forums (or RIMU for the default installation). Following are the steps I took:

Set up the necessary X11 libs for Java AWT:

you need to copy libXp.so.6.2 from an existing Linux installation /usr/X11R6/lib into /usr/X11R6/lib (I took them from a RHEL3 install)

cd /usr/X11R6/lib
ln -s libXp.so.6.2 libXp.so.6

The next steps are not crucial for this application, but it keeps things a little nicer for me
ln -s libXp.so.6 libXp.so
ln -s libICE.so.6 libICE.so
ln -s libSM.so.6 libSM.so
ln -s libX11.so.6 libX11.so
ln -s libXext.so.6 libXext.so
ln -s libXt.so.6 libXt.so
ln -s libXtst.so.6 libXtst.so
End Optional Section

Change the startup script for Tomcat:

immediately after the JAVA_HOME export statement, add the line
export JAVA_OPTS="-Djava.awt.headless=true"

Reset the library links:

ldconfig

Restart Tomcat:

/etc/rc.d/init.d/tomcat restart

You should then be able to test your image generation code successfully.

Good luck!

retep
06-22-2005, 05:35 AM
Which distro are you running? We should have all the necessary libs pre-installed on our VPSs, and if not I'd like to know so we can do so on new setups.

Also, rather than copying around libs from other servers, you should just be able to install them via apt. In this case I think the package you need to install goes like this:
apt-get install -y xorg-x11-deprecated-libs

Finally: our /usr/local/tomcat/bin/setenv.sh should already have "-Djava.awt.headless=true" in it. But that option is indeed necessary to do headless (i.e. create graphics without an X server running on your VPS).