[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: How to execute a perl script in Java?
- From: Robin Berjon <robin@knowscape.com>
- To: Giota Karadimitriou <karadim@iti.gr>
- Date: Tue, 13 Mar 2001 13:42:43 +0100
At 14:18 13/03/2001 +0200, Giota Karadimitriou wrote:
>The URL to the perl script is http://www.w3.org/2000/04/schema_hack/.
>As for the 'but', I didn't want to degrade perl as a language.
>Perl is indeed a great solution for dealing with text but the fact is that I
>need
>java not perl code.
>Still, does anybody know if a perl script can be executed from java?
This is probably not exactly the solution you're looking for but if you're
ok with running JavaServer and aren't afraid of a few lines of Perl code
you might want to look at http://search.cpan.org/search?dist=Java. It's a
complete Perl interface to a local or remote JVM. Something along the lines of:
use Java;
my $java = Java->new;
my $your_app = $java->create_object('gr.iti.yourApp');
$java->do_event($your_app, \&dtd2xsd);
sub dtd2xsd {
my $app = shift;
# call the script from Perl space
# and return the value by setting it on your object
$app->set_field('returnValue',$foo);
}
# simplistic event loop
while(1) {
last if not defined $java->go;
}
It's a bit of a hack because your Java app will have to generate an event
to call the Perl code, and the above Perl program + JavaServer will have to
run continuously if you want to have the functionality available at any
time. Another option you might want to look into is
http://search.cpan.org/search?mode=module&query=jasmin which generates
Jasmin assembler from Perl code but I don't know how complete/stable it is,
and chances are you'll need a fairly recent Perl.
-- robin b.
Always remember you're unique just like everyone else.