A Look Inside the O'Reilly Perl Resource Kit
By Brian Jepson
The
Java-Perl Library (JPL) written by Larry Wall, provides runtime linkage between Perl and Java. With JPL, you can embed Perl within Java. In theory, you can also embed Java within Perl, but a deficiency in the current Sun JDK makes this difficult (more on this later).
This article will demonstrate how you can use JPL with Java servlets to get the best of both worlds. It's like mixing up servlets with mod_perl. I decided to use mod_jserv, because it's freely redistributable, it's my favorite servlet engine, and it runs on my favorite Web server (Apache).
What is JPL?
More importantly, what isn't JPL? Most importantly, it's not a tool for turning Perl code into Java bytecode or for turning Java code into Perl bytecode.
JPL provides nearly seamless mapping between Java and Perl. Behind the scenes, JPL converts Perl data types into sensible Java equivalents (and vice versa). JPL is part of O'Reilly & Associates' UNIX Perl Resource Kit. In a nutshell, JPL lets you combine the best of Perl and Java in a relatively painless fashion.
Before We Dive In
Before we see JPL in action, let's start out with a simple Perl program, which we'll port to JPL so we can take advantage of Java's graphical user interface.