Starting Multiple OpenOffice Instances

To use multiple OpenOffice instances you have to:

  • Start one instance with its own user directory; $HOME on UNIX or %USERPROFILE% on Windows
  • Use different TCP/IP ports

For server mode use options to not display logo at startup (-nologo), to not draw a frame (-headless or -invisible), skip the first start wizard (-nofirststartwizard) and to prevent crash reports (-nocrashreport) as in these situations OOo tries to show a dialog which will prevent your instance from working. As OOo may restart automatically if an exception occured and display a dialog to send a report, you want to display this behavior using the -norestart option.

I wrote a small shell script to start several instances on my Mac. You can easily adopt it for other Unices by pointing OOO_HOME to your installation directory:

#!/bin/sh
OOO_HOME=/Applications/OpenOffice.org.app/Contents
OOO_HOST=
OOO_PORT="2002 2003 2004 2005"
USER_HOME=/tmp

_create_home() {
    port=$1
    home=${USER_HOME}/user/port${port}
    mkdir -p ${home}
    echo ${home}
}

_start_instances() {
    # Go to OOo program folder
    cd ${OOO_HOME}/program
    # Set IP address
    host=${OOO_HOST:-127.0.0.1}
    # All ports... default is standard port 2002
    for port in ${OOO_PORT:-2002}
    do
        # Set user home
        HOME=$(_create_home ${port})
        export HOME
        # Start OOo
        echo "Starting OpenOffice on ${host}:${port} using home directory ${HOME}"
        sock="socket,host=${host},port=${port},tcpNoDelay=1;urp;StarOffice.ServiceManager"
        opts="-nologo -nofirststartwizard -nodefault -nocrashreport -norestart -nolockcheck -headless"
        nohup ./soffice -userid="${HOME}" -accept="${sock}" ${opts} 1>soffice_${port}.log 2>&1 &
    done
}

_start_instances
exit 0
This entry was posted in Odisee, Software Development and tagged . Bookmark the permalink.