JInterface question

Per Hedeland per@REDACTED
Fri Feb 11 22:36:46 CET 2000

Nick Collier <nick@REDACTED> wrote:
>I'm experimenting with the JInterface library and am having some
>problems getting it to work. 
>I've written a simple java application that creates an OtpServer and
>publishes the server's port. I can see that it is registered with epmd
>when I do an epmd -names. However, I can't my erlang program to register
>with epmd. I can start the shell with -sname which then registers the
>shell with epmd, but how do I get anything run within the shell to be
>epmd aware?

I'm afraid I know next to nothing about Jinterface (and not much more
about Java:-), but you seem to be a bit confused about the Erlang side of
things - browsing the Jinterface docs, I'll venture a guess that this
confusion stems from the fact(?:-) that on the Java side, a process and a
node are basically the same thing, i.e. there is only one process per
node - not so on the Erlang side, of course.

I.e., -sname doesn't register the shell with epmd, it registers the
entire Erlang node, i.e. instance of the runtime system. And Erlang
processes don't need to be "epmd aware", or even necessarly "distribution
aware" - they often just send their messages to some Pid (Process Id),
which may or may not be on the same node.  If a message is destined for
another node, and no connection previously exists, one is made in a
manner that is basically transparent to the sending process.

So, you don't need to get "your erlang program to register with epmd",
that is already done via the -sname at startup (or via net_kernel:start()
after startup, if you prefer). To get the two nodes to talk to each other
initially, they need to know about each other (or at least one needs to
know about the other), either via configuration or via e.g. Erlang's
net_adm:names(). Once that is out of the way, contact is typically
established by means of sending a message to a registered process on the
other node, or perhaps via spawn/4 (of course many of these low-level
details are hidden when you use OTP).

(I'm guessing that spawn/4 doesn't work in either direction of the
Erlang-Java communication, while sending to a registered process works in
both directions, with the registered name being ignored when going

--Per Hedeland

More information about the erlang-questions mailing list