Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Perl and Java Objects

by ptoulis (Scribe)
on Jan 12, 2009 at 15:13 UTC ( [id://735700]=perlquestion: print w/replies, xml ) Need Help??

ptoulis has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I have two separate programs, one in Perl and the other in Java which have to communicate to a certain degree. Until now, I have managed to get through, using the loopback interface and exchanging simple messages over TCP. For the beginning, this worked well because data formats were simple and so were the messages (e.g. "login <username> <password>")

However, as the the whole application becomes more complex, I have to use a more efficient way so that Perl and Java share (or exchange) more complex objects. My colleagues use ZeroC for their code, but ICE does not have a port to Perl yet..Another way could be the CORBA-Perl module, but it has little documentation which makes me reluctant.

Since this is a Robotics project with limited time constraints, I would like to give a quick and robust solution for inter-operating Perl and Java objects. Is there any appropriate solution for that?

Thanks a lot!

Replies are listed 'Best First'.
Re: Perl and Java Objects
by moritz (Cardinal) on Jan 12, 2009 at 15:25 UTC
    If you just want to exchange data structures, you might take a look at JSON and YAML. There are pretty good Perl bindings for both, and I suspect that there are also Java libraries for both.

    COBRA CORBA is usually used when you need more features, for example callbacks into the remote system.

    Update: fixed name of that protocol, Arunbear++

Re: Perl and Java Objects
by Fletch (Bishop) on Jan 12, 2009 at 15:25 UTC

    Depending on the exact value of "complex" you might be able to get by with JSON (links to Java implementations at that link, with either JSON::XS or JSON::Syck on the Perl side) or YAML (YAML::Syck on the Perl side, again links to Java implementations at link). SOAP::Lite might be worth investigating as well.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Perl and Java Objects
by samtregar (Abbot) on Jan 12, 2009 at 19:56 UTC
    I can't believe no one has mentioned Inline::Java! It works great and does exactly what you're asking for. You can either combine your two programs into one or have them remain separate but use a native remote interface (like Java RMI for example) to communicate.

    -sam

Re: Perl and Java Objects
by bassplayer (Monsignor) on Jan 12, 2009 at 15:59 UTC
    I would agree with both of above posts about JSON -- quite easy to use, likely Java has good support, and is quick to get going with. I would be wary of SOAP::Lite, however, especially with regards to your limited time contraints.

    bassplayer

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://735700]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found