Friday, November 16, 2007

Java from the command line and GUI dependence

Calling a .jar file from the command-line in headless mode--say, from a web-server--seems to pose a problem under OS X Tiger, in that java requires communication w/ the GUI system. (This leads me to believe that the problem applies under Linux as well.)

The solution is the "-Djava.awt.headless=true" parameter; for example, here's how I call the Batik SVG rasterizer:
/usr/bin/java -Djava.awt.headless=true -jar /Library/WebServer/Documents/py/archive/batik-1.7/batik-rasterizer.jar -w 1000 -h 1000 -bg xxx.svg

I knew I didn't trust that newfangled Java.

No comments: