The following link provides a tutorial with code samples
Chapter 5: JNI Technology