Automatically launching X11 shared apps

In this, my first Wonderblog entry, I will show you how to automatically launch X11 shared apps in Wonderland. In Release 0.5 we plan to provide a Wonderland File System (WFS) feature that you can use to specify apps which are to be automatically launched when the world first starts up. You will be able to do this without modifying the Wonderland code. In the Release 0.4 code (i.e. the current CVS trunk at the time of this writing) it is possible to automatically start X11 shared apps but only with code modifications. I’ve integrated some commented out examples of how to do this. All you need to do is uncomment the code and modify it for the app or apps you wish to automatically launch.

Automatically Launching Server Apps

Usually you want to automatically launch an application when the world is first being initialized. The application will be launched before any normal clients connect to the server. This section demonstrates how to do this.

In lg3d-wonderland/src/classes/org/jdesktop/lg3d/wonderland/appshare/ServerMasterClient.ServerMasterClient() uncomment the following line:

            // Note: Uncomment this to activate SMC automatic shared X11 app launching
            // Here is an example of automatically launching a shared X11 app from the SMC when it starts up

Then modify the following method:

     // Here is an example of automatically launching a shared X11 app from the SMC when it starts up
    private void autoLaunchSharedX11Apps () {

        // Launch an app which is defined on a Shared Apps SMC menu
        Iterator appIterator = AppConfigX11Examples.smcIterator();
        while (appIterator.hasNext()) {
            AppConfigX11Example appConfig = (AppConfigX11Example);
            if (appConfig.getAppMenu().equals("Team Room") &&
            appConfig.getName().equals("Center Firefox")) {
            System.err.println("Auto-launching the Team Room Center Firefox");


This method will scan the lg3d-wonderland/src/config/apps-{linux,solaris}/apps-smc.xml Shared Apps menu definition file for a particular app (in this case the Center Firefox) in the team room and will launch it after the SMC is finished with its initialization.

Note: during my testing I have observed the following exception occur when a normal Wonderland client first connects but it appears to be innocuous and therefore can be ignored.

      [java] Exception in thread "Escher-DinReader" gnu.x11.Error: #Error
     [java]   code: 10 BAD_ACCESS: operation right denied
     [java]   sequence-number: 42
     [java]   major-opcode: 2 ChangeWindowAttributes
     [java]     at gnu.x11.MessageFactory.build_error(
     [java]     at
     [java]     at gnu.x11.DinReader.readMessage(
     [java]     at

Automatically Launching Local Apps on Linux and Solaris

Locally launched X11 shared apps are supported on the Linux and Solaris platforms. Sometimes you may wish to launch a particular local X11 client when your client connects to the server. This section demonstrates how to do this.

In lg3d-wonderland/src/classes/org/jdesktop/lg3d/wonderland/ uncomment the following code (which is at the end of the method):

     /* Note: Uncomment this to activate local automatic shared X11 app launching

    // Here is an example of automatically locally launching a shared X11 app from a normal Wonderland client
    // when it first starts up.
    // NOTE: Reminder: if initInBestView for the app is set to true in apps.xml this will bring up the
    // in approximately the best view of the initial view location. Note that in MPK20 the initial slide
    // show may therefore obscure the app. To place the locally launched app in a specific location set
    // initInBestView to false and set the cellPosition.x,y,z and cellRotateY parameters.

    if (!ServerMasterClient.iAmTheServerMasterClient()) {

        // Bug workaround: wait 10 seconds. there is a bug which can occur if you launch
        // an app before the Wonderland art assets are fully loaded and initialized
        // NOTE: you may need to tweak this value for your situation
        try { Thread.sleep(10000); } catch (InterruptedException ex) {}

        // Launch an app which is defined on the local menu
        Iterator appIterator = AppConfigX11Examples.iterator();
        while (appIterator.hasNext()) {
            AppConfigX11Example appConfig = (AppConfigX11Example);
            if (appConfig.getAppMenu().equals(AppConfigX11Example.LOCAL_MENU) &&
                appConfig.getName().equals("Firefox")) {
                System.err.println("Auto-launching a local Firefox");

This code first checks to make sure it is only run on a client other than the SMC. It then waits a bit for the Wonderland scene graph to be initialized (launching an app before this occurs can fail due to a bug). Note that you may need to adjust this wait for your particular situation.

Finally, please make sure you read the NOTE above about the initInBestView parameter.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: