Graciliano Monteiro Passos


PLJava - This project will embed Perl into Java.


  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() ;
     "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




Home & Download:

Perl 5.6+


Download from:


First install the Java and Perl binaries.

Don't forget to set the enverioment variables for Java. Examples:


You also will need to have the Java and Perl binaries in the search PATH:


After have the binaries well installed just type:

  Perl MakeFile.PL

Now you are able to run the example:

  nmake test
  ## or:
  java test

Note that after build PLJava you will have a ./built directory with all the files needed to be with your Java application. In this directory you also will have the example to test it in this directory.


Java package: perl5

All the compiled Java classed will be inside the perl5 package/directory.

To use PLJava from your Java application you will need this files in the main diretory of your application:

  PLJava.dll     ## The PLJava library that loads the Perl interpreter.      ## Perl side of PLJava.
  Perl56.dll     ## The Perl library in case that you have Perl built dynamic.
  perl5/*        ## Diretory with PLJava classes.
  lib/*          ## A Perl lib directory with basic .pm files (strict, warnings, etc...)

Take a look in the ./built directory after build PLJava.


The source files generated by SWIG (, PLJava_wrap.c, come already built for your convenience. If you want to install SWIG to generate this files again just type:

  nmake swig


Download from:

** Don't forget to add SWIG in the search PATH:



You will need to have VC++ 6 to compile PLJava, since your Perl version for Win32 (from ActiveState) will be probably compiled with VC++, and we need the same compiler of the interpreter to embed a Perl program.


I haven't tested it on Linux yet, but should work!


The support to call Perl from Java from multiple Java Threads was added and tested on Win32, where Threads are native.

Note that if you are compiling PLJava with Perl 5.8+ you can use Perl Threads too.


Graciliano M. P. <>

I will appreciate any type of feedback (include your opinions and/or suggestions). ;-P


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.