in reply to Re: How to call perl in Java?
in thread How to call perl in Java?

Not very sure, actually. Maybe I need to have java objects passed as perl sub arguments. For example:
In foo.pm
package foo; sub run_foo { my($obj1,$obj2) = @_; # access passed java object $obj1->method; $obj2->attribute; } 1;
In java:
PerlEnviromnent foo = loadPerlPackage("foo.pm"); foo.runSub('run_foo',some_object,another_object);

Replies are listed 'Best First'.
Re^3: How to call perl in Java?
by dHarry (Abbot) on Jan 08, 2010 at 08:45 UTC

    Passing Java objects to Perl subs sounds tricky, objects can be arbitrary complex. Maybe you can use JSON for data transfer. You could serialize your Java object to a JSON string, pass it to Perl and decode it. See JSON in Java and JSON.

    HTH

    Harry

      I know that Inline::Java is able to use Java objects in perl code...

        Perhaps I was not clear, for the JSON approach I meant communication between a JVM and Perl, not as in Java glued into Perl, i.e. the inline solution. If you're happy with mixing java and Perl in one file it seems like the most straightforward solution to me. I'd prefer to separate things. Is it a use-once solution or will you need this type of communication a lot in the future? It might be worthwhile to explore other solutions. More work though.

        Cheers

        Harry