package provides a high-level model of Erlang-style processes and
communication in Java. You can use this package alone to give Erlang-style
concurrency in Java, or you can use it as part of a mixed Java/Erlang
distributed system, allowing a Java system to contain Erlang components or
A Java package such as
consists of a collection of Java classes, mostly beginning with the prefix
Otp. This section will describe the
most common of them, providing examples of passing messages and handling
data types when communicating between Erlang and Java. You can find
additional information on
and its Erlang classes in the “Interface and Communication Applications”
section of the Erlang/OTP documentation. The running example for this
section is a rework of the remote procedure call (RPC) example in Chapter 11.
We described Erlang nodes in Chapter 11, where we also introduced distributed programming in Erlang. An Erlang node is identified by its name, which consists of an identifier with a hostname (in short or long form); each host can run a number of nodes, if their names are different.
OtpNode class gives the
representation of an Erlang node:
OtpNode bar = new OtpNode("bar");
This creates the Java object
bar—which we’ll call a
node—that represents the Erlang node
bar, running on the host where the statement
You can create a process on this node by creating a mailbox, which is ...