Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by gmpassos (Priest)
on Jul 13, 2004 at 03:50 UTC ( #373839=perlmeditation: print w/ replies, xml ) Need Help??

Hello monks,

Recently I have posted a prototype of Perl embeded into Java (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 it 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 in 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:
http://www.cpan.org/authors/id/G/GM/GMPASSOS/PLJava-0.01.tar.gz
http://www.cpan.org/authors/id/G/GM/GMPASSOS/PLJava-0.01.readme

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

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.
"Creativity is the expression of the liberty".

Comment on PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
Download Code
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by jacques (Priest) on Jul 13, 2004 at 04:22 UTC
    I think you should rename this "Pava" because PLJava just isn't catchy . . .

    Oh, and I think this is great. :)

      How about

      Palava

      :)

      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
        Then lava (pa lava)? I prefer blue (plava) myself ;)

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

        Plava (Laguna)

        - tye        

        P.S. It should be implemented as a mul-ti-pass compiler.

      Also, PlJava could be confused with embedding Java in the PostgreSQL database server, also called PlJava or Pl/Java.
      I just recently came to know about PLJava. These articles were written in 2004. Has there been any more developments or advancements in this area? I have googled for quite a few days for better solutions but have not found anything more yet.
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by gmpassos (Priest) on Jul 13, 2004 at 07:14 UTC
    Hey folks, I holp that this node will be much more than only a name discussion (again)!

    Sincerely, I don't care to much about the name of the things. Thanks for who sent suggestions, but lets take a look in other pictures!

    Graciliano M. P.
    "Creativity is the expression of the liberty".

      lol I can understand that perfectly. I ++'d this node.

        Bad namers of the world UNITE!!!
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by Tomte (Priest) on Jul 13, 2004 at 10:48 UTC

    Great stuff, here are the testresults of the Gentoo-Jury: g.m.passos douze points ;-)

    Update:crossposted this test-result to comp.lang.perl.modules.

    [1239]tom@margo PLJava-0.01 $ perl -v This is perl, v5.8.4 built for i686-linux

    Makefile.PL diff (diff -c)

    Changes to the generated Makefile:

    s/-rdynamic/-shared -rdynamic/

    Inside of built/

    [1244]tom@margo PLJava-0.01 $ export LD_LIBRARY_PATH=.:$LD_LIBRARY_PAT +H [1245]tom@margo built $ ln -s PLJava.so libPLJava.so [1245]tom@margo built $ java test
    java test output:

    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).

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      Wow, many thanks for the updates for Linux!

      I will add them to PLJava and release a new version...

      And, it works! It's alive.... heheeh ;-P

      Graciliano M. P.
      "Creativity is the expression of the liberty".

        Dear Graciliano,

        I donwloaded the PLJava and run it in Winxp. I have set the enverioment variables for Java. While I compile the Makefile.pl with perl, it return below errors:

        ---------------------------------------------
        Note (probably harmless): No library found for oldnames.lib
        Note (probably harmless): No library found for kernel32.lib
        Note (probably harmless): No library found for user32.lib
        Note (probably harmless): No library found for gdi32.lib
        Note (probably harmless): No library found for winspool.lib
        Note (probably harmless): No library found for comdlg32.lib
        Note (probably harmless): No library found for advapi32.lib
        Note (probably harmless): No library found for shell32.lib
        Note (probably harmless): No library found for ole32.lib
        Note (probably harmless): No library found for oleaut32.lib
        Note (probably harmless): No library found for netapi32.lib
        Note (probably harmless): No library found for uuid.lib
        Note (probably harmless): No library found for ws2_32.lib
        Note (probably harmless): No library found for mpr.lib
        Note (probably harmless): No library found for winmm.lib
        Note (probably harmless): No library found for version.lib
        Note (probably harmless): No library found for odbc32.lib
        Note (probably harmless): No library found for odbccp32.lib
        Note (probably harmless): No library found for msvcrt.lib
        Writing Makefile for PLJava
        -------------------------------------------------------

        What is the problem cause this error and how to fix it?

        Regards,
        CC
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by Anonymous Monk on Jul 21, 2005 at 17:11 UTC
    Hello Graciliano, I have it PLJava working under OS X 1.3.9. Most impressed. I built and installed it by hand as I don't know how to go about changing the Makefile.PL appropriately. I can't get email through to your address as given on CPAN, gm@virtuasites.com.br , is there some other way to reach you ?
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by metaperl (Curate) on Jul 22, 2005 at 17:23 UTC
    yes, "PLJava" makes me think of something similar to PL/SQL - very misleading naming.
      I agree. Terrible name.
        howabout PeiJ! -Rikin
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by Anonymous Monk on Mar 24, 2008 at 01:51 UTC
    Sure I'm late and this is not the most important but I would like tu suggest a new name which could be familiar for those used to Java: perl4java or simply perl4j
      I recently came to know about PLJava. But these articles were written in 2004. Has there been any more developments or advancements in this area? I have googled for quite a few days for better solutions but have not found anything more yet. I need to use the PPI modules and maybe the B::* modules also for a Netbeans Plugin that I am writing in Java. http://code.google.com/p/nbperl/
Re: PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please.
by Anonymous Monk on Jun 03, 2011 at 07:18 UTC

    Hi, The PLJava sounds interesting. Can i get complete documentation of it? How can i get values returned by a method from Perl in Java when i call it from Java? Thanks in advance.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://373839]
Approved by ysth
Front-paged by meredith
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-07-13 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (249 votes), past polls