A few examples


import liburbi.main.*;

/// Callback for images
class onImage extends UCallbackInterface {

  public UCallbackAction onMessage(UMessage msg) {
    if (!(UMessageType.MESSAGE_DATA == msg.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    UValue value = msg.getValue ();

    if (!(UDataType.DATA_BINARY == value.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    UBinary bin = value.getUBinary ();

    if (!(UBinaryType.BINARY_IMAGE == bin.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    UImage img = bin.getUImage ();
    byte[] data = img.getDataAsByte ();

    System.out.println("Image of size " + img.getWidth () + "x"
                       + img.height + " received");

    /// myDisplay*Image are custom functions not part of liburbi-java
    /// replace by your own code
    if (img.imageFormat == UImageFormat.IMAGE_JPEG)
      myDisplayJPEGImage (data, img.getWidth (), img.getHeight ());
    else if (img.imageFormat == UImageFormat.IMAGE_YCbCr)
      myDisplayYCbCrImage (data, img.getWidth (), img.getHeight ());
    else if (img.imageFormat == UImageFormat.IMAGE_RGB)
      myDisplayRGBImage (data, img.getWidth (), img.getHeight ());

    return UCallbackAction.URBI_CONTINUE;
  }
}

/// Callback for sound
class onSound extends UCallbackInterface {

  public UCallbackAction onMessage(UMessage msg) {
    if (!(UMessageType.MESSAGE_DATA == msg.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    UValue value = msg.getValue ();

    if (!(UDataType.DATA_BINARY == value.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    UBinary bin = value.getUBinary ();

    if (!(UBinaryType.BINARY_SOUND == bin.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    USound sound = bin.getUSound ();

    byte[] data = img.getDataAsByte ();

    System.out.println("Sound received");
    return UCallbackAction.URBI_CONTINUE;
  }
}

/// Callback for joint value
class onJoint extends UCallbackInterface {

  public UCallbackAction onMessage(UMessage msg) {
    if (!(UMessageType.MESSAGE_DATA == msg.getType ()))
      return UCallbackAction.URBI_CONTINUE;
    UValue value = msg.getValue ();

    if (!(UDataType.DATA_DOUBLE == value.getType ()))
      return UCallbackAction.URBI_CONTINUE;

    System.out.println("The joint value is " + value.getDouble ());
    return UCallbackAction.URBI_CONTINUE;
  }
}

public class test {
  static {
    /// Load the C++ liburbi library and the jni code.
    System.loadLibrary("urbijava");
  }

  public static void main(String argv[]) {

    UClient c = new UClient(argv[1]);

    if (c.error() != 0)
    {
	System.out.println("Couldn't connect to the URBI server.");
	System.exit(1);
    }

    onImage oi = new onImage ();
    onJoint oj = new onJoint ();
    onSound os = new onSound ();

    c.setCallback (oi, "img");
    c.setCallback (oj, "snd");
    c.setCallback (os, "joint");

    c.send("img: camera.val;");
    c.send("loop snd: micro.val,");
    c.send("joint: headPan.val;");


    liburbi.execute (); /// function that do a infinite sleep
  }
}