javah -classpath . -jni 类路径.JNIClass(提供的接口,编译后)
/**
*TokenFxxcImpl类中方法声明方式
*/
public static native Object[] getCreditTokenJni(long meterNo, int sgc, int tariffIndex,
int keyVersion, int keyExpiredTime, long keyNo, int seqNo,
int amount);
示例:F:\android program\Fxxc_T\bin>javah -classpath . -jni com.fxxc.TokenFxxcImpl
- F:\android program\Fxxc_T\bin 为编译后的包路径
- javah -classpath . -jni 生成.h的java命令
- com.fxxc.TokenFxxcImpl 编译后的class带包名的路径
- 执行完后会在bin目录下生成.h文件com_fxxc_TokenFxxcImpl.h
.h文件内对应方法接口如下
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_fxxc_TokenFxxcImpl */
#ifndef _Included_com_fxxc_TokenFxxcImpl
#define _Included_com_fxxc_TokenFxxcImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_fxxc_TokenFxxcImpl
* Method: getCreditTokenJni
* Signature: (JIIIIJII)[Ljava/lang/Object;
*/
JNIEXPORT jobjectArray JNICALL Java_com_fxxc_TokenFxxcImpl_getCreditTokenJni
(JNIEnv *, jclass, jlong, jint, jint, jint, jint, jlong, jint, jint);
#ifdef __cplusplus
}
#endif
#endif
最后在C语言中实现H文件中的方法就行