Skip to content

Running without a Display

Ben Fry edited this page Jun 15, 2015 · 11 revisions

Let's say you want to run a Processing sketch on a server. Like maybe you want to generate several million PDF and JPEG images using a handful of Amazon EC2 instances.

This is called “headless” mode, and to do so, it's necessary to install what's known as a virtual frame buffer.

On Ubuntu 14.04, these are the things you need to install first:

sudo apt-get install xvfb libxrender1 libxtst6 libxi6 

Then you create a fake "display" that Processing can use:

sudo Xvfb :1 -screen 0 1024x768x24
export DISPLAY=":1"

Finally, run a sketch that's been exported as a Linux application from the PDE.

Why?

It's necessary to use the virtual frame buffer because it would require a truly ridiculous amount of work to make Processing so general that it could be done without a display. This would involve a great deal of code and abstraction that simply doesn't make sense when 99.9999% of the code created with Processing will be run with a display. Happily, this method works well and prevents us from needing to double the size of PApplet.

Headless Mode

Another option is to mess with the command line parameters that launch Java. If you add -Djava.awt.headless=true to the line that runs the java command, that may be all you need. Read more about Java's Headless Mode here. For most cases, this is less likely to work, but may provide clues for how to get a more complicated sketch running on your machine.