How to compile dynamic library for a JNI application on linux?

Native library can be loaded by loadLibrary with a valid name. By example, libXXXX.so for linux family, your hellolib.so should rename to libhello.so. By the way, I develop java with jni, I will separate the implementation and native interface (.c or .cpp). static { System.loadLibrary(“hello”); // will load libhello.so } The implementation header(HelloImpl.h): #ifndef _HELLO_IMPL_H …

Read more

Should Java finalizer really be avoided also for native peer objects lifecycle management?

finalize and other approaches that use GC knowledge of objects lifetime have a couple of nuances: visibility: do you guarantee that all the writes methods of object o made are visible to the finalizer (i.e., there is a happens-before relationship between the last action on object o and the code performing finalization)? reachability: how do …

Read more