piyush.shourie has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,

Is there any way to use Java modules in Perl code? This can be something similar to using C/C++ code through XS layer.

Any pointers to related articles would be very beneficial.

Thanks in advance,
Piyush

Replies are listed 'Best First'.
Re: Use of Java modules in Perl
by inman (Curate) on Nov 04, 2004 at 08:52 UTC
    Take a look at Inline::Java. This module does exactly what you are looking for. Take a look at the replies to this node - 392445 which asked the same question.

    You can also Super Search for inline java and get some useful info.

Re: Use of Java modules in Perl
by reneeb (Chaplain) on Nov 04, 2004 at 08:53 UTC
    I think you can't use it in a direct way, but you can use the module Inline::Java. As you can see in the section "METHODS" of the documentation you can "import" Java-packages.
Re: Use of Java modules in Perl
by Tomte (Priest) on Nov 04, 2004 at 09:00 UTC

    Your exact problem may not be solveable with Inline::Java, but I'd give it a try.

    Although the content is kind of sparse ATM, you maybe want to check back inline.perl here and then.

    regards,
    tomte


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

Re: Use of Java modules in Perl
by prefect (Sexton) on Nov 04, 2004 at 12:41 UTC
    I use the Java module for doing something like this, although I'm not sure if it's exactly what you're asking about. With Java, I start up a JVM and call Java classes from my Perl code.
Re: Use of Java modules in Perl
by Anonymous Monk on Nov 04, 2004 at 17:55 UTC
    I suppose it would be possible to have your java program act as a "main" method, call down into JNI, and from JNI embed a perl interpreter which would (by various function calls) manipulate the Java code while in JNI land (JNI allows for all sorts of Java language abuses, including private variable access). JNI ain't fun though, nor is embedding an interpreter.

      If your interpretation of the OPs meaning is right, and using perl in java is a viable solution, gmpassos' PLJava would be the first thing to look at...

      regards,
      tomte


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