Inline::Java::PerlInterpreter - Call Perl directly from Java using Inline::Java.


   import* ;

   class HelpMePerl {
      static private InlineJavaPerlInterpreter pi = null ;

      public HelpMePerl() throws InlineJavaException {

      static private boolean matches(String target, String pattern)
        throws InlineJavaPerlException, InlineJavaException {
        Boolean b = (Boolean)pi.eval("'" + target + "' =~ /" + pattern + "/", Boolean.class) ;
        return b.booleanValue() ;

      public static void main(String args[])
             throws InlineJavaPerlException, InlineJavaException {
         pi = InlineJavaPerlInterpreter.create() ;

         String target = "aaabbbccc" ;
         String pattern = "ab+" ;
         boolean ret = matches(target, pattern) ;

           target + (ret ? " matches " : " doesn't match ") + pattern) ;
         pi.destroy() ;


WARNING: Inline::Java::PerlInterpreter is still experimental.

The Java class allows you to load a Perl interpreter directly from Java. You can then perform regular callbacks to call into Perl.



Before using, you must have installed Inline::Java as well as the JNI extension. Additionally, the PerlInterpreter extension must also have been installed.

Finding the jar

To be able to use the class, you must use the jar file provided by Inline::Java. You can easily locate this jar file using the following command:

   % perl -MInline::Java=jar

You must then add this jar file to your CLASSPATH as you would any jar file.

Basic Usage itself extends See Inline::Java::Callback for information on the callback API.

Besides that API, provides only 2 other public methods:

public InlineJavaPerlInterpreter create() throws InlineJavaPerlException, InlineJavaException

Creates a new object. This class in a singleton.

public void destroy()

Destroys the Perl interpreter.


Inline::Java, Inline::Java::Callback, Inline::Java::PerlNatives.


Patrick LeBoutillier <> is the author of Inline::Java.


Copyright (c) 2001-2004, Patrick LeBoutillier.

All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License. See for more details.