java调用C++:
#include <jni.h>
//导出c函数格式
extern "C" JNIEXPORT
//供JNI调用
JNICALL
函数名格式 Java_包名_类名_函数名(包名.替换为_)
Java_com_example_getapplist_MainActivity_stringFromJNI
包名:com_example_getapplist 类名:MainActivity. 函数名:stringFromJNI
#include <jni.h>
#include <string>
//导出c函数格式
extern "C" JNIEXPORT jstring
//供JNI调用
JNICALL
//函数名格式 Java_包名_类名_函数名(包名.替换为_)
Java_com_example_getapplist_MainActivity_stringFromJNI(
JNIEnv *env, //JNI环境
jobject //类对象
) {
//string对象
std::string hello = "Hello from C++";
//string转换为jstring
return env->NewStringUTF(hello.c_str(