JNI, The Java Native Interface

Standard programming interface for writing Java native methods and embedding the Java virtual machine into native applications.

Website: http://download.oracle.com/javase/6/docs/technotes/guides/jni/index.html, http://java.sun.com/docs/books/jni/
Platforms supported: Win32, Linux
Headers to include: jni.bi
Header version: from 2006
Examples: in examples/other-languages/Java/

Three files:
#include "jni.bi"
'' Note: The mangling must be "windows-ms" or the JRE won't find any function
Extern "windows-ms"
    Function Java_MyLib_add( env As JNIEnv Ptr, obj As jobject, l As jint, r As jint ) As jint Export
        Return l + r
    End Function
End Extern

class MyLib {
    public native int add( int l, int r );
    static {
        System.loadLibrary( "mylib" );

class Test {
    public static void main(String[] args) {
        MyLib lib = new MyLib();
        System.out.println( "2+2=" + lib.add( 2, 2 ) );

Steps to test it:

Back to External Library Table of Contents
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki

sf.net phatcode