dcsimg

How do i throw an Exception from C/C++ JNI code?

Davanum Srinivas

Use ThrowNew as shown below:

jclass exc = env->FindClass("java/lang/NullPointerException");
if (exc != NULL)
    env->ThrowNew(exc, "(in C++ code)");