PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. Perl Tk vs Java Swing
      In article <d3a7a97fafe0879879f4ac380e45a27f@localhost.talkaboutprogramming.com>, pnguruji <pguruprasad@lucent.com> wrote: Ah! There are at...
    2. 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...
    3. 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...
    4. 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...
    5. 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,...
  3. #2

    Default 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:
    > 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.
    Great stuff, here are the testresults of the Gentoo-Jury: g.m.passos douze
    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

  4. #3

    Wink 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139