develooper Front page | perl.jpl | Postings from June 2004

Re: Best way to call java from perl

Thread Previous | Thread Next
From:
ced
Date:
June 10, 2004 16:08
Subject:
Re: Best way to call java from perl
Message ID:
200406102255.PAA10462@carios2.ca.boeing.com
>I am willing to call a java class method from perl and capture its output. As I
>understand there are three different ways to do it, but not sure which is the be
>st way to go about.

>1. Using inline java module I can define the java class within perl itself
>2. executing commandline through perl (using System or something ?)
>3. using JPL module

>Any thoughts? Is there any other simpler way to call java class method from perl

Since you're calling from Perl, I'd recommend 2. if possible since
that's easiest. That'd limit you to just capturing the output/error
streams from the Java program however. You'll need to use the Perl 
backticks rather than 'system' (or maybe even IPC::Open3 if you want
to winnow out stdout/stderr). See perlop, perlfaq's etc. for more
about the backtick operator.  

If something more elaborate is required such as instantiating a Java 
object and calling its methods, you'll need Inline::Java.   

JPL, I think, is limited to embedding Perl in Java. It does that very 
well and is best used in legacy Java apps which need to leverage 
something Perl does better than Java.


Hope this helps,
--
Charles DeRykus

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About