How to Run Multiple/Concurrent OpenOffice.org Instances on Windows

In one of the project at work we have been using OpenOffice.org running in headless mode to do document format conversions in the background, i.e. converting to and from various MS Office formats OpenDocument formats and PDF. One problem of using standalone OpenOffice.org installation as backend is that you can only run one instance at a time. So while you can have a multi-user front end doing various processing, we used to be able to run document format conversion one at a time.

That sucks.

Here's a trick to run multiple OpenOffice.org instances concurrently, all from one single installation, on Windows. Assuming the latest OpenOffice.org 3.x is installed. It's actually pretty simple -- just change the USERPROFILE environment variable! Or HOME on Linux/Solaris.

For example, in Java

ProcessBuilder pb = new ProcessBuilder("c:\\Program Files\\OpenOffice.org 3\\program\\soffice.exe",
    "-accept=socket,host=localhost,port=7999;urp;StarOffice.ServiceManager",
    "-invisible", "-headless", "-nologo", "-nofirststartwizard");
Map<String, String> env = pb.environment();
if (windoze) {
    env.put("USERPROFILE", "c:\\temp\\12345");
} else {
    env.put("HOME", "/tmp/12345");
}
Process ooo = pb.start();

Yeah I am putting this here because the search result on Google is pretty junky. And I just realised that I have not blogged for yonks. Busy buys busy.