Java Messages for Erlang

I am making an application in Erlang with a GUI in Java. I managed to establish a connection between the languages, but now I need (I think) to send a message from Java to Erlang, every time I press a button, for example.

Is this the right way?

What would such a message look like?

I found some good sites about this form of integration, but I feel like I'm not getting everything.

http://www.trapexit.org/How_to_communicate_java_and_erlang

+6
erlang integration otp
source share
3 answers

If jinterface is too complicated, you can just use the package option in open_port and use

byte[] in_buf = new byte[256]; byte[] out_buf = new byte[256]; int in_count = System.in.read (); int offset = 0; do { int c = System.in.read (in_buf, offset, in_count-offset); offset += c; } while (offset < in_count); 

To read packages from erlang and to write use:

 System.out.write(out_count); System.out.write(out_buf, 0, out_count); 

On the erlang side it will fit

 open_port({spawn, "<path-to-java> -cp <classpath> your-java-prog", [{packet, 1}]). 

If you need larger packages, use {package, 2} or {package, 4} and adapt java. Inside the packages, you can run any protocol that you like on both sides.

+2
source share

In addition to the classic Java-Erlang communication through the OTP interface, you can explore methods such as:

  - thrift - ice from zeroC (no official erlang binding) - maybe two http servers on both sides (I like this approach) - protocol buffers (rather not, it is better for larger data transfers) 

You need to study the form of your traffic and choose the best solution. Jinterface is not so bad, tho .. (here is the official document: http://www.erlang.org/doc/apps/jinterface/jinterface_users_guide.html )

+3
source share

I am working on an application similar to yours: C ++ GUI and Erlang server. I use TCP sockets for messaging between the graphical interface and the server and Erlang server templates for processing requests (I can have several graphical interfaces connected to the server at the same time).

+1
source share

All Articles