Although we try to make our applications pure Java, outside forces sometimes
make this impossible. We had such a case recently in our shop when we had to
interface to an external device with an API that supported C language calls.
This is a typical case for the Java Native Interface (JNI). The JNI provides
Java programs with a gateway to other languages and enables applications
written in other languages to invoke the Java Virtual Machine.
This article focuses on the first of these two uses. Specifically, it
discusses supporting a C/C++ API in Java to allow a Java application to use
it. This is probably the situation in which the JNI is most frequently
employed in production environments. Indeed, the seminal work on the JNI, The
Java Native Interface: Programmer's Guide and Specification by Sheng Liang,
devotes a chapter to this question. There's no theory involved, b... (more)