Ask a Question related to PERL Modules, Design and Development.
-
Graciliano M. P. #1
PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
Recently on perlmonks.com I have posted a prototype of Perl embeded into
Java (#372197="Embeding Perl into Java to use CPAN modules directly from
Java"), as a simplier alternative for JPL (not any more in development). One
advantage over JPL is that PLJava works on Win32.
Now I have finished the basic wrappers to work with Perl from Java,
specially to control and use Perl objecs directly from Java. Also I have
added support for multiple Java Native Threads calling the same Perl
interpreter, so, is possible to use PLJava with Java RMI, since for each RMI
application you have a Thread that is not the main.
Also I have wrapped the basics of the module XML::Smart to Java as class
XMLSmart.
Note that PLJava was made to be installed into Java, or to be with your Java
applications, and not to be installed on Perl. So, you can publish your Java
application using Perl without need to ask for the user to install Perl to
run it.
The 1st release is at:
[url]http://www.cpan.org/authors/id/G/GM/GMPASSOS/PLJava-0.01.tar.gz[/url]
[url]http://www.cpan.org/authors/id/G/GM/GMPASSOS/PLJava-0.01.readme[/url]
I have tested it on Win32, and need some test over Linux yet, but it should
work, at least with small changes.
I will appreciate any type of feedback. Thanks in advance. ;-P
Regards,
Graciliano M. P.
USAGE
import perl5.Perl ;
import perl5.SV ;
public class test {
public static void main(String argv[]) {
Perl.eval("print qq`Hello World!\n` ;") ;
///////////////////
SV foo = Perl.NEW("foo") ; // $foo = new foo() ;
foo.call("subtest") ; // $foo->subtest() ;
///////////////////
String s = Perl.eval(" 'time: ' + time() ") ;
int i = Perl.eval_int(" 2**10 ") ; // 1024
int n = Perl.eval_int(" 10/3 ") ; // 3
int d = Perl.eval_double(" 10/3 ") ; // 3.33333333333333
///////////////////
SV array = Perl.eval_sv(" [ 'a' , 'b' , 'c' ] ") ;
String e0 = array.elem(0) ; // a
String e1 = array.elem(1) ; // b
String e2 = array.elem(2) ; // c
///////////////////
SV hash = Perl.eval_sv(" { a => 11 , b => 22 , c => 33 } ") ;
String k_a = hash.key("a") ; // 11
String k_b = hash.key("b") ; // 22
String k_c = hash.key("c") ; // 33
}
}
Graciliano M. P. Guest
-
Perl Tk vs Java Swing
In article <d3a7a97fafe0879879f4ac380e45a27f@localhost.talkaboutprogramming.com>, pnguruji <pguruprasad@lucent.com> wrote: Ah! There are at... -
Java / PHP / Perl programmer, Dublin based
Hi, Are you looking for Java / PHP / Perl programming ? Do you need custom Java / PHP / Perl components ? Do you need to accelerate production... -
Perl and Java scripts
Hi, I'm trying to read values in from the stockmarket and I have found a site where I have an update of the stocks every minute but to be able to... -
Calling a Java SP with an embeded subselect crashes DB
I've tested this on several PCs, all have the same issue. I create a Java SP (using the wizard or manually) with at least one parameter that is a... -
Perl keeps me from throwing up while programming java
use strict; use warnings; use Tk; my $top = MainWindow->new(); my $t1 = $top->Scrolled( 'Text', -scrollbars=>'se', -height=>5, -width=>40,... -
Tom Regner #2
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
crossposting of
[url]http://www.perlmonks.org/index.pl?node_id=373910[/url]
Graciliano M. P. wrote:Great stuff, here are the testresults of the Gentoo-Jury: g.m.passos douze> Now I have finished the basic wrappers to work with Perl from Java,
> specially to control and use Perl objecs directly from Java. Also I have
> added support for multiple Java Native Threads calling the same Perl
> interpreter, so, is possible to use PLJava with Java RMI, since for each
> RMI application you have a Thread that is not the main.
points ;-)
Summary: the dll-naming is wrong (libPLJava.so), the object-file-ending is
wrong, and inside the generated Makefile an option to gcc is missing
(without the -shared gcc needs a main-function).
[1239]tom@margo PLJava-0.01 $ perl -v
This is perl, v5.8.4 built for i686-linux
Makefile.PL diff (diff -c)
** Makefile.PL 2004-07-13 00:20:42.000000000 +0200
--- Makefile.PL.linux 2004-07-13 12:41:27.000000000 +0200
***************
*** 32,38 ****
#########
my $C_FILES = "$NAME.c ${NAME}_wrap.c" ;
! my $O_FILES = "$NAME.obj ${NAME}_wrap.obj" ;
my $INTERFACE = "$NAME.i" ;
my $CLEAN_FILES = "PLJava.dll" ;
--- 32,38 ----
#########
my $C_FILES = "$NAME.c ${NAME}_wrap.c" ;
! my $O_FILES = "$NAME.o ${NAME}_wrap.o" ;
my $INTERFACE = "$NAME.i" ;
my $CLEAN_FILES = "PLJava.dll" ;
***************
*** 103,109 ****
CFLAGS=$cflags
LDFLAGS=$ldflags
! INC = -I"$ENV{JAVA_INCLUDE}" -I"$ENV{JAVA_INCLUDE}/win32"
C_FILES = $C_FILES
O_FILES = $O_FILES
--- 103,109 ----
CFLAGS=$cflags
LDFLAGS=$ldflags
! INC = -I"$ENV{JAVA_INCLUDE}" -I"$ENV{JAVA_INCLUDE}/win32"
-I"$ENV{JAVA_INCLUDE}/linux"
C_FILES = $C_FILES
O_FILES = $O_FILES
***************
*** 115,121 ****
DISTNAME = $NAME
VERSION = $VERSION
SUFFIX = .gz
-
DISTVNAME = \$(DISTNAME)-\$(VERSION)
.c$o:
--- 115,120 ----
Changes to the generated Makefile:
s/-rdynamic/-shared -rdynamic/
Inside of built/
[1244]tom@margo PLJava-0.01 $ export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
[1245]tom@margo built $ ln -s PLJava.so libPLJava.so
[1245]tom@margo built $ java test
java test output:
java test
Hello World!
TIME: 1089715216
@INC:
/lib
/usr/lib/perl5/5.8.4/i686-linux
/usr/lib/perl5/5.8.4
/usr/lib/perl5/site_perl/5.8.4/i686-linux
/usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3/i686-linux
/usr/lib/perl5/site_perl/5.8.3
/usr/lib/perl5/site_perl/5.8.2/i686-linux
/usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1/i686-linux
/usr/lib/perl5/site_perl/5.8.1
/usr/lib/perl5/site_perl/5.8.0/i686-linux
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.4/i686-linux
/usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3/i686-linux
/usr/lib/perl5/vendor_perl/5.8.3
/usr/lib/perl5/vendor_perl/5.8.2/i686-linux
/usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1/i686-linux
/usr/lib/perl5/vendor_perl/5.8.1
/usr/lib/perl5/vendor_perl/5.8.0/i686-linux
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
Tom Regner Guest
-
Nidhi Kushwaha #3
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for
hello;
I have to ask that if my project is on java , and i have to add one module which is in Perl,then how i use that module.Nidhi Kushwaha Guest



Reply With Quote

