PerlOnJava provides a Perl distribution designed to run natively on the Java Virtual Machine (JVM). It allows Perl scripts to integrate seamlessly with Java-based ecosystems while offering familiar tools and modules for Perl development.
The JAR package features a variety of Perl modules, such as DBI
(with JDBC support), HTTP::Tiny
, JSON
, YAML
, File::Find
, and Data::Dumper
.
Users can also add their own database JDBC drivers, making it a flexible solution for cross-platform Perl applications.
- Introduction
- Why PerlOnJava
- Target Audience
- Quick Start
- Features and Limitations
- Build Instructions
- Running with Docker
- Running the JAR File
- Debugging Tools
- Architecture
- Porting Modules
- Milestones
- Community and Support
- License
- Additional Resources
PerlOnJava bridges the gap between Perl and Java by providing a platform that compiles Perl scripts into Java bytecode, making them executable on the JVM. By leveraging this distribution, developers can run familiar Perl code while accessing Java's ecosystem of libraries and tools. This project aims to bring the strengths of Perl to modern JVM environments while supporting a growing list of core modules and pragmas.
Need help? Check out our Community and Support section.
- A JVM-Native Perl Implementation: Runs Perl code directly on the Java Virtual Machine
- A Bridge to Java Ecosystems: Enables Perl scripts to interact with Java libraries and frameworks
- A Cross-Platform Solution: Provides consistent Perl behavior across different operating systems via JVM
- A Modern Integration Tool: Allows Perl codebases to participate in Java-based enterprise environments
- Java Developers with Perl Knowledge: Provides a method for integrating Perl scripts into Java applications.
- Compiler and Language Enthusiasts: Offers insights into translating high-level languages into JVM bytecode.
- Experimenters and Tinkerers: A tool for experimenting with language interoperability.
Get started quickly with PerlOnJava. For a complete list of capabilities, see our Feature Matrix.
-
Build the project (detailed instructions):
mvn clean package
-
Run a simple Perl script:
Linux/Mac
./jperl -E 'say "Hello World"'
Windows
jperl -E "say 'Hello World'"
-
Use Perl in your Java application:
import javax.script.*; public class TestPerl { public static void main(String[] args) throws Exception { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("perl"); engine.eval("print 'Hello from Java-integrated Perl!\n'"); } }
-
Connect to a database:
use DBI; my $dbh = DBI->connect("jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1"); $dbh->do("CREATE TABLE test (id INT, name VARCHAR(50))"); $dbh->do("INSERT INTO test VALUES (1, 'Hello World')");
- Show Instructions:
Linux/Mac
./jperl --help
Windows
jperl --help
- Execute Something:
Linux/Mac
./jperl -E 'print 123'
Windows
jperl -E "print 123"
- Execute Emitting Debug Information:
Linux/Mac
./jperl --debug -E 'print 123'
Windows
jperl --debug -E "print 123"
- Compile Only; Can Be Combined with --debug:
Linux/Mac
./jperl -c -E 'print 123'
./jperl --debug -c -E 'print 123'
Windows
jperl -c -E "print 123"
jperl --debug -c -E "print 123"
- Execute and Emit Disassembled ASM Code:
Linux/Mac
./jperl --disassemble -E 'print 123'
Windows
jperl --disassemble -E "print 123"
- Run the Lexer Only:
Linux/Mac
./jperl --tokenize -E 'print 123'
Windows
jperl --tokenize -E "print 123"
- Run the Parser Only:
Linux/Mac
./jperl --parse -E 'print 123'
Windows
jperl --parse -E "print 123"
This project is licensed under the Perl Artistic License 2.0 - see the LICENSE file for details.