jInterface to create External Erlang Term <p>How can I format the the following erlang term:</p> <pre><code>{ atom, "message" } </code></pre> <p>In jInterface to an external format that I may call in an erlang shell</p> <pre><code>erlang:binary_to_term( Binary ) </code></pre> <p>Example: Note that since the tuple will be sent over the net, I finish by converting to byte[].</p> <pre><code>OtpErlangObject[] msg = new OtpErlangObject[2]; msg[0] = new OtpErlangAtom( "atom" ); msg[1] = new OtpErlangString( "message" ); OtpErlangTuple reply = new OtpErlangTuple(msg); OtpOutputStream stream = new OtpOutputStream(reply); stream.toByteArray() // byte[] which I send over net </code></pre> <p>The binary received by Erlang is:</p> <pre><code>B = &lt;&lt;104,2,100,0,4,97,116,111,109,107,0,7,109,101,115,115,97,103,101&gt;&gt; </code></pre> <p>Then in an erlang shell converting the received term to binary gives a badarg.</p> <pre><code> binary_to_term( B ). ** exception error: bad argument in function binary_to_term/1 called as binary_to_term(&lt;&lt;104,2,107,0,4,97,116,111,109,107,0,7,109, 101,115,115,97,103,101&gt;&gt;) </code></pre>