As might have been expected, obtaining Java functionality from native
code via JNI function calls turned out to be much slower than pure JIT-optimized Java. Nevertheless, the overhead factor rarely exceeded 30
what is acceptable in most cases as JNI functions typically take only a
small part in total native method execution time. Therefore, the overall
JNI performance seems to be adequate for most applications where it
really have to be used."
So i think the following JNI Wrapper for Delphi and FreePascal is really useful, and it works on Windows (and i will perhaps soon port it to
Linux), but notice in the following that the Market share of Windows is
So here is JNI Wrapper for Delphi and FreePascal version 2.94 JNI that i
have enhanced much more, and i think it is stable and complete, as you
will notice that now JNI Wrapper automatically configure itself from the Windows registry to support new versions of Oracle Java.
Authors: Jonathan Revusky, Amine Moulay Ramdane and Salvatore Meschini.
This JNI Wrapper for Delphi and FreePascal provides a powerful and
simplified object-oriented API for doing mixed language programming in
Java and Delphi (Object Pascal language) or FreePascal. This may provide
an easier and more productive way of getting Win32 and Win64 features in
Java projects and integrating legacy code (at least for the Delphi or FreePascal community). Please read the readme file inside the zip file
to learn more.
I have noticed that JNIWrapper for Delphi and FreePascal was not
supporting returning of Strings and Arrays types from Java, so i have implemented that and i have now enhanced JNI Wrapper to be very powerful
, so it's now supporting all the necessary functions and methods and and
much more... hope you will happy with it cause i have worked hard to
bring this new 2.94 to you, it is really now a professional software of
a good quality.
Also i have enhanced more JNI Wrapper and ported it to 64 bit and to
both FreePascal and the Delphi XE versions and to Delphi tokyo, here is
the functions that i have implemented and added:
function JstringArrayToDTStrings(jarr : JArray) : TStrings;
function JdoubleArrayToDdoubleArray(jarr : JdoubleArray) : TDdoubleArray;
function JfloatArrayToDsingleArray(jarr : JFloatArray) : TDsingleArray;
function JcharArrayToDwordArray(jarr : JCharArray) : TDwordArray;
function JbyteArrayToDshortintArray(jarr : JByteArray) : TDshortintArray;
function JshortArrayToDsmallintArray(jarr : JShortArray) : TDsmallintArray;
function JbooleanArrayToDbooleanArray(jarr : JBooleanArray) :
And don't forget to call TJavaVM.freeRef() method from Delphi or
FreePascal when you need to garbage collect and free the memory that was allocated.
You can download JNI Wrapper for Delphi and FreePascal version 2.94 from
my website here: