Java 代码:
package nativeCaller;
public class call_dll {
static
{
System.load("netCashierDll");
}
public native void helloWord();
}
我的工程目录在 E:\Users\chen-bo\workspace\netCash_Software
通过DOS命令进入 cd E:\Users\chen-bo\workspace\netCash_Software\src\nativeCaller文件夹 编译xx.java
E:\Users\chen-bo\workspace\netCash_Software\src\nativeCaller>javac call_dll.java
返回包的上一级目录 编译生成.h文件
E:\Users\chen-bo\workspace\netCash_Software\src\nativeCaller>cd ..
E:\Users\chen-bo\workspace\netCash_Software\src>javah -jni nativeCaller.call_dll
头文件代码:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class nativeCaller_call_dll */
#ifndef _Included_nativeCaller_call_dll
#define _Included_nativeCaller_call_dll
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: nativeCaller_call_dll
* Method: helloWord
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_nativeCaller_call_1dll_helloWord
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif