JNI helloworld

JNI is easy to use when you know how and frustrating when you don’t. I hope to demystify it and provide some pointers to when it goes wrong. Define your native methods using the native modifier. In this example we’ll add two numbers together. public class HelloWorld { public native int add(int a, int b);… Continue reading JNI helloworld

Published
Categorized as geek Tagged ,

JNI asynchronous callbacks

If you’re using JNI, you may wish to callback a java method asynchronously. For example event handling from a win32 message pump. package com.adamish; public class Foo { public native void register(); public void callback(int val) { // do stuff } } Step one is to have a “register” method which lets the C++ code… Continue reading JNI asynchronous callbacks

Published
Categorized as geek Tagged ,