Coach Thrasher
Java CAPTCHA rendering without X11
I've been asked a few times about how to get JCAPTCHA or other java-based captcha libraries to work on unix or linux without X11 running. The answer is simple: start the Java virtual machine with a system property set:
java -Djava.awt.headless=true myprogram.jar
Or if you are running with Apache Tomcat, which is serving the captcha.jpg image files, you need to pass a variable to the shell script that handles starting and stopping of Tomcat: catalina.sh (or catalina.bat). There's a facility already in catalina.sh to handle this: it uses the "JAVA_OPTS" environment variable. Personally I've found it easiest to set this property for all users in the /etc/profiles file, so that all users have the same settings when they login. Here's the line to add to that file:
export JAVA_OPTS=-Djava.awt.headless=true
If you don't have root access and can't get your admin to make this change, then you can set it on your user account in unix by adding the same line to the file ~/.bash_profile.
Posted at 02:14PM Jun 22, 2006 by jason in Software | Comments[0]