How do I make a call like this:
order_cat(Pid, Name, Color, Desc) ->
gen_server:call(Pid, {order, Name, Color, Desc}).
to something like this:
handle_call({order, Name, Color, Desc}, _From, Cats) ->
if Cats =:= [] ->
{reply, make_cat(Name, Color, Desc), Cats};
Cats =/= [] ->
{reply, hd(Cats), tl(Cats)}
end;
handle_call(terminate, _From, Cats) ->
{stop, normal, ok, Cats}.
by using java and Jinterface instead of the first code? I know how to send a message to a pid using Jinterface, but then I have a recieve statement that handles it. I want to use OTP instead but I don't understand how.
There are two ways to connect to your Erlang code through Jinterface: messages and RPC.
RPC is documented here: http://www.erlang.org/doc/apps/jinterface/jinterface_users_guide.html#id57655
Note that it is not "non-OTP" to use messages. If you've got a gen_server, you can message it directly and receive the message in the handle_info function.