Calling C Code From Java Using JNI

1 · Frank Dai · July 23, 2015, 9:28 a.m.
This blog is a fork of http://stuf.ro/calling-c-code-from-java-using-jni with some errors fixed and C++ support added. In this tutorial we’ll be creating a Java application calling code from a native library. We’ll have a Java application called HelloWorld which will call the function helloFromC from a shared library named ctest, using Java Native Interface. First off, we’ll create a file named HelloWorld.java to contain the HelloWorld class. 1 2 3 4 5 6 7 8 9 10 /* HelloWorld.java */ public cl...