> I'm in a project which requires me to invoke Perl from Java using BSF
> (Bean Scripting Framework ).
>
I've written something to do exactly this!

http://bsfperl.sourceforge.net

> To cut the story short, I need to embed a Perl interpreter within a
> JNI (C/C++) wrapper and then pass Perl fragments to the interpreter.
>
This is not the approach that I took.  Rather than using JNI and
embedding a native interpreter, I instead spawn off Perl as a
sub-process (using Runtime.exec) and then pass a serialized form of
data back and forth between the two processes.  Communication still
occurs transparently in both directions, but there's a bit of
additional overhead to doing it this way.  The advantage, however, is
that all you need to run this is a standard JRE installation, a
standard Perl installation, and my jar -- no native code or modified
Java/Perl installations are required.

> This is all fine except that on the Perl side, I need to invoke Java
> objects created on the Java end and at the same time, be able to
> create Java objects on the Perl side and pass them back to Java.
>
Hmm.  Assuming that you have some type of factory written in Java
which is vending out new objects, this will work fine.  If you want to
the ability to directly instantiate Java classes from Perl, I don't
believe this is currently supported.  I'll add an enhancement request
for this and will make sure it gets in version 0.2, but in the mean
time you should be able to work-around this limitation pretty easily.

Let me know if you need any help,
Don

--- Original Message ---

Subject: RE: Java and Perl integration (comments are appreciated)
From: (Ed Yu)
Newsgroups: perl.inline
Date: Mar 08 2004 12:25:19

> Hi Patrick,
> 
> Thanks for your reply. I'm not in a "hurry hurry", but I do have to
> project how long it will take to accomplish this and convey it to my
> supervisor. What is your projected available date?
> 
> I would like to extend my help to you if possible. Unfortunately, I
> don't really know much about Perl and the Inline::Java project, but I
> have done a good bit of Java with some JNI work. Is there a CVS
> repository that I can tap into your current work?
> 
> I looked into JPL but it seems like the project is not as active as it
> should and it really has a static flavor and I would like to have more
> of a run-time dynamic approach which is supported under Inline::Java. In
> other words, I think it is easier to start JVM on my own and invoke JNI
> to embed a Perl interpreter and perform some Inline::Java initalization
> such that it taps into the existing JVM instead of starting a new one.
> 
> My real goal is to come up with BSH support for Perl using Inline::Java
> and I would hate to hack out pieces between Inline::Java and JPL to get
> it done.
> 
> Again, thanks for your reply and looking forward to your current work.
> 
> 
> > -----Original Message-----
> > From: Patrick LeBoutillier [mailto:[EMAIL PROTECTED] 
> > Sent: Monday, March 08, 2004 10:21 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Java and Perl integration (comments are appreciated)
> > 
> > 
> > > Ed,
> > >
> > > I'm currently working on implementing such functionnality 
> > at this very 
> > > moment. I'll keep this list informed as usual when it is available.
> > >
> > > If you are in a hurry, you can try taking a look at JPL. I know it 
> > > provided functionnality similar to what you are looking for, but I 
> > > don't what the state of the project is.
> > >
> > > Patrick
> > >
> > >
> > >
> > > On Sun, 2004-03-07 at 14:57, Ed Yu wrote:
> > >> Hi all,
> > >>
> > >> I've found lots of good resources about how to use Java 
> > within Perl 
> > >> (i.e. Inline::Java). I'm in a project which requires me to invoke 
> > >> Perl from Java
> > >> using BSF (Bean Scripting Framework ). To cut the story 
> > short, I need to
> > >> embed a Perl interpreter within a JNI (C/C++) wrapper and 
> > then pass Perl
> > >> fragments to the interpreter.
> > >>
> > >> This is all fine except that on the Perl side, I need to 
> > invoke Java 
> > >> objects created on the Java end and at the same time, be able to 
> > >> create Java objects
> > >> on the Perl side and pass them back to Java.
> > >>
> > >> My understanding is that Inline::Java actually uses the revese 
> > >> strategy, spawing a JVM and use either JNI or client/server to 
> > >> communicate with the JVM. In addition, mapping/remapping Perl and 
> > >> Java objects are also a part of
> > >> the Inline::Java module.
> > >>
> > >> Any comments to how this can be accomplished is appreciated.
> > >>
> >> Many thanks.



Reply via email to