This workaround enables processing applications to run on a headless linux machine, e.g. a server. I needed the functionality for the automatic generation of graphics on a debianbox without a graphical user interface and because processing requires a graphics enviroment this was the way to go.
- edit your sketch as usual in processing, until you are satisified with the results
- export a application from processing.
- copy the folder application.linux to your headless box. there needs to be java installed on this machine. how to install java on debian? (german)
- if you now execute the script you get something like: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
- to make java think there is a display we must use a virtual framebuffer. Xvfb is an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory.
- install Xvfb. on debian this would be:
sudo aptitude install xvfb
- now you have to modifiy the script where java is called, it looks something like this:
#!/bin/sh
APPDIR=$(dirname "$0")
java -Djava.library.path="$APPDIR"
-cp" $APPDIR/lib/Array.jar:$APPDIR/lib/core.jar" \
Array
- insert this line:
export DISPLAY=localhost:1.0
to get this:
#!/bin/sh
export DISPLAY=localhost:1.0
APPDIR=$(dirname "$0")
java -Djava.library.path="$APPDIR"
-cp" $APPDIR/lib/Array.jar:$APPDIR/lib/core.jar" \
Array
- start Xvfb:
Xvfb :1 -screen 0 1152x900x8 -fbdir /tmp &
- now you should be able to run your sketch.
- remember to stop Xvfb when you’re finished
all this makes only sense, if you want to use processing to output data, e.g. pdfs, because you won’t (and actually do not want) to see anything. if you need to import dynamic data from the data-folder in your processing file hierarchy, you have to open the jar-file inside the lib folder and remove the data-folder. otherwise the application will only access the data-folder inside the jar.
these workaround is based on the article:
Grafikverarbeitung ohne grafische Oberfläche