jnic calls java code

https://blog.csdn.net/qq_36523667/article/details/80093935

This article contains configuration and java call c

This article builds on the above based on c calling java


The c code is replaced as follows

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_demo_Utils */
#ifndef _Included_com_example_demo_Utils
#define _Included_com_example_demo_Utils
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     com_example_demo_Utils
 * Method:    get
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_com_example_demo_Utils_get

  (JNIEnv *env, jobject thiz) {
    jclass dpclazz = (*env)->FindClass(env, "com/example/demo/GoGo");
jmethodID methodID = (*env)->GetStaticMethodID(env, dpclazz,"get", "()Ljava/lang/String;");
jstring result = (*env)->CallStaticObjectMethod(env,dpclazz,methodID);
return result;
}            

#ifdef __cplusplus
}
#endif
#endif

The original return is

(*env)->NewStringUTF(env, "666")


operation result


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325646029&siteId=291194637