JNI – Java Native Interface
How to persuade my Java application to talk
         to evil evil C native code
•   WHAT?
•   WHY?
•   WHY NOT?
•   THE ACTUAL CODE
•   GOODIES
Er… WHAT?

      Java applications




     Native applications
But, but…

 WHY?
But, but…

         WHY?

Allows native API function calls
But, but…

         WHY?

Usage of existing native libraries
But, but…

         WHY?

Execution of time-critical code
OK, so

     WHY NOT?
 Use of JNI should be avoided
whenever reasonably possible!
Example

Java native function declaration first:
Example
Example
Example
Example
Example
Example




Careful!
Example
Example
Example
Exceptions?!
           Doable but annoying.
Other things to know


• Forget about garbage collection

• Java JVM is nazi about its memory space
I DON’T EXIST

jernej@virag.si
Skype: izacus

Jni – java native interface