<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi Dan,<br>
<br>
It is easiest to use the jinterface library for this task, since it
is included within OTP/Erlang. The version value is included within
the jinterface code that is needed for port communication. Most
people use system out/in for ports, but then you are unable to get
any print statements, which can be annoying... and often stderr is
lost. If you look at CloudI (<a class="moz-txt-link-freetext" href="http://cloudi.org/">http://cloudi.org/</a>), it makes sure to
open a port (using C++ loader code to exec the JVM) which starts a
bunch of sockets with deterministic file descriptor numbers
(starting at 3), then uses the jinterface library to encode/decode
Erlang data used in the Java CloudI API. So, the example is more
complex, but it avoids stdout/stderr (1/2) and handles those
separately within the C++ loader code (sending it back as port
communication). The higher-level usage of jinterface is similar to
what you want, if you ignore some of the magic to make the integer
file descriptors work within the java source code
(<a class="moz-txt-link-freetext" href="https://github.com/okeuday/CloudI/blob/master/src/api/java/org/cloudi/API.java">https://github.com/okeuday/CloudI/blob/master/src/api/java/org/cloudi/API.java</a>).<br>
<br>
- Michael<br>
<br>
On 07/11/2011 03:14 PM, Daniel Dormont wrote:
<blockquote
cite="mid:CAGYOVV1A_KvqMPK+OyijD4VR0qe+jbni-P0zjKhS5tf=YfQ-TQ@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
Hello Erlangers,<br>
<br>
I would like to have an Erlang application (specifically the
auth_external module in Ejabberd) communicate with a Java program
I am writing. Not as a node, but rather using the port driver API,
since that is what Ejabberd already supports. From the information
I've seen, it shouldn't be too terribly hard - just listen for
data in System.in, look for a two-byte chunk that when read as a
short specifies the number of additional bytes to read, and
repeat. I'm just wondering if this is something that's considered
normal and reasonable to do, any gotchas I should be aware of,
etc.<br>
<br>
The only reason I'm picking Java is the rest of my application is
Java and I'd like to reuse some libraries and such.<br>
<br>
thanks,<br>
Dan<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>