Getting Started

There is no installation required. Just add MozartSpaces as library to your project (CLASSPATH) and you can start using it.

You need to create an instance of a MozartSpaces core to access a space. In the default configuration, an embedded space is automatically created with the core instance. The example below shows how an object can written and then read from such an embedded space.

Hello, space!

The code snippet below creates a MozartSpaces core instance with an embedded space. An instance of the synchronous core API (Capi) is used to access the core. First a container is created. Containers are used to structure the space and define how the entries, the user data objects, are coordinated. See the tutorial for information about containers, coordination and entries. In this simple example the default coordination is used when the string "Hello, space!" is written to the container and read afterwards. At the end the created container is destroyed and the core with the embedded space is shut down.

MzsCore core = DefaultMzsCore.newInstance();
Capi capi = new Capi(core);
ContainerReference container = capi.createContainer();
capi.write(container, new Entry("Hello, space!"));
ArrayList<String> resultEntries =;
System.out.println("Entry read: " + resultEntries.get(0));
capi.destroyContainer(container, null);

You do not need to create a new class and copy this code, you can download this and other examples here.

Multiple spaces

The example above uses only a single embedded space, but a Capi instance allows for easy access to other spaces, for the example above with the overloaded method createContainer. Spaces are identified with URI's and can be the embedded spaces of other program instances or standalone instances.

Standalone instance

A MozartSpaces standalone instance is a process with a space that is remotely accessible for other peers. It can be started with the following command:

$ java -cp mozartspaces-dist-2.3-SNAPSHOT-all-with-dependencies.jar org.mozartspaces.core.Server [port]

This starts the class org.mozartspaces.core.Server, optionally with the port where the space should be reachable. If no port is specified, the default port 9876 is used. You can configure the space further as explained below.


MozartSpaces can be configured with an XML file or programmatically. Both configuration variants can be combined but are completely optional, MozartSpaces uses internal default values for not explicitly configured options. The example programs contain a configuration file named mozartspaces.xml which contains some explanation of the configuration options. Further information is available in the tutorial, and, for the programmatic configuration, in the Javadoc.

MozartSpaces uses logback for logging, which has its own configuration. An example configuration file for logback, logback.xml, is included in the examples.