PBJ::JNI

PBJ::JNI is a Perl module with full access to and from Java virtual machine from Perl.
Download

PBJ::JNI Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ping Liang
  • Publisher web site:
  • http://search.cpan.org/~ping/PBJ-JNI-0.1/lib/PBJ/JNI.pm

PBJ::JNI Tags


PBJ::JNI Description

PBJ::JNI is a Perl module with full access to and from Java virtual machine from Perl. PBJ::JNI is a Perl module with full access to and from Java virtual machine from Perl.SYNOPSIS use PBJ::JNI::JavaVM; my ($env, $jvm, @vm_opts); my ($cls, $fid, $mid, $out); # Create the Java VM @vm_opts = ("-Xrs", "-Xcheck:jni"); $jvm = new PBJ::JNI::JavaVM(); $env = $jvm->get_env(@vm_opts); $env->PushLocalFrame(16) == 0 or die; $cls = $env->FindClass("java/lang/System") or die; $fid = $env->GetStaticFieldID($cls, "out", "Ljava/io/PrintStream;") or die; $out = $env->GetStaticObjectField($cls, $fid) or die; $cls = $env->GetObjectClass($out) or die; $mid = $env->GetMethodID($cls, "println", "(I)V") or die; $env->CallVoidMethod($out, $mid, $env->cast("I", 12345)); $env->PopLocalFrame(0);WARNINGThis software is still in alpha stage. It may not be reliable and its features and APIs may change in the future releases.The PBJ::JNI package allows you to link with your Java virtual machine and directly access Java classes from Perl. It also allows a mechanism to create callbacks from Java program to Perl subroutines.The package focuses on providing a set of APIs that closely resemble the native JNI interface. This basically means that you can write an ordinary JNI program in Perl instead of in C or C++. This provides a quicker way to writing wrappers to invoke programs written in Java and therefore introduce Java libraries to the Perl without the trouble of writing low level C/C++ programs.You will need to know how JNI works in order to use this package. This package is by definition very primitive. If you don't understand thoroughly on how JNI works and try to use the feature of this package, you can easily crash your program or create memory leaks. So don't do that.It is my hope that somebody with proper skills in JNI and Perl can write wrappers for a set of popular Java libraries, such as JDBC, XML parser, JMS (that I am working on), and other useful Java packages so that a Perl programmer can use them directly in a pure Perl environment without knowing anything about JNI.Requirements:· Perl Requirements: · Perl


PBJ::JNI Related Software