Chris,

You should definitely look into Inline::Java. Inline::Java basically
allows you to bind Java classes so that you can use them transparently
from Perl.

You can write your own Java code (Inline style) or ask Inline::Java to
study some classes from jar files so that you can use them.

Inline::Java has 2 working modes: client/server and JNI. With
client/server your Perl program starts a JVM and connects to it via TCP
to automate it. When the Perl program terminates the JVM is terminated
as well (although the SHARED_JVM option allows the JVM server to live on
if you want to reuse it later). In JNI mode your Perl program will
dynamically load libjvm.so and do all the Java stuff in the same
process.

So basically your scenario could look something like this:



#!/usr/bin/perl

BEGIN {
        $ENV{CLASSPATH} = '/your/jar/file.jar'
}

use Inline (
        Java => 'STUDY'
        STUDY => [
                'some.class.from.the.jar.file',
                'some.other.class.from.the.jar.file'
        ],
) ;

# Do your Perl stuff

# When you need to:
my $o = new some::class::from::the::jar::file() ;
my $answer = $o->some_method_that_does_something_useful(
        1, 2, 4, "blablabla") ;



I think this is pretty much along the lines of what you want/need to do.

Patrick

On Wed, 2004-04-07 at 18:14, Chris Dawson wrote:
> (cross-posted on advice from Ingy...)
> 
> I have been using perl SOAP for a while now and really like the 
> simplicity compared to other toolkits.  I have a project, however, where 
> I need to use a third party java library (.jar) to do work backend 
> work.  I was thinking of using Inline.pm to run the java code, and then 
> have this perl wrapper also manage the SOAP interface, calling into the 
> java when necessary.  The java is actually going to run a subshelled 
> compiled C program...  This may be a vague question, but I will ask it 
> anyway.  Does anyone have experience using perl in this way, in other 
> words, to manage a java interpreter in a program which will sit as a 
> daemon for long periods of time?  Are there tricks I can use to minimize 
> startup time of the java interpreter?  Is this generally a bad idea?  
> For example, my code will likely do something as follows:  run the perl 
> program, bring up the SOAP server, wait for a command; upon a start 
> command, start the JVM and execute until the stop command is processed.  
> Any thoughts?
> 
> Thx,
> Chris

Reply via email to