
February 15th, 2004, 08:10 AM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
JNI - it`s not slow !
Hi,
In the last 6 months I had the chance to integrate a Java with a C application using the JNI. The author of this article recommends not to use JNI if possible, because it would be slow.
I contradict at this point. There is actually no other possibility to connect a Java environment with applications written in C in one address space. Of course, the loading of the native library is expensive, but the call of native methods is as fast as any other Java method call.The native function is within the same address space, and the function pointer is directly accessible.
The JNI is a brilliant idea, especially for people who want to integrate system software with Java applications. Although I have to say, that this interface is even one of the most complicated ones that Java has to offer. One should have a good knowledge of C programming, multithreading and the Java concept of memory management.
Anyway, this article provides a good and easy example for JNI beginners. For professional applications of JNI I recommend the
books of Sheng Liang and and Rob Gordon.
|