【参考文章】:javah javac 命令行生成native的方法教程
项目需要调用 C++动态库,由于项目包结构发生变化,需要重新生成本地方法的头文件,使用 javah 不得要领,遂使用 javac 命令,记录一下基本使用方法。
-encoding utf8 指定源文件编码格式
-h . 头文件的输出目录,. 表示当前目录
NativeCpp.java 源文件
/* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class com_streamax_s17_fms_business_jni_NativeCpp */ #ifndef _Included_com_streamax_s17_fms_business_jni_NativeCpp #define _Included_com_streamax_s17_fms_business_jni_NativeCpp #ifdef __cplusplus extern "C" { #endif /* * Class: com_streamax_s17_fms_business_jni_NativeCpp * Method: parseBlacBox * Signature: (Ljava/lang/String;II)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_com_streamax_s17_fms_business_jni_NativeCpp_parseBlacBox (JNIEnv *, jobject, jstring, jint, jint); #ifdef __cplusplus } #endif #endif
原文:https://www.cnblogs.com/virgosnail/p/10711165.html