日期:2014-05-17 浏览次数:20755 次
public class JniCall {
static {
System.loadLibrary("testJNA");
}
public native static int add(int first, int second);
public static void main(String[] args) {
int first = 3;
int second = 4;
System.out.printf("print in java : %d + %d = %d", first, second, add(first, second));
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class JniCall */
#ifndef _Included_JniCall
#define _Included_JniCall
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: JniCall
* Method: add
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_JniCall_add
(JNIEnv *, jclass, jint, jint);
typedef struct Student {
char * name;
int age;
int height;
}StudentObj;
#ifdef __cplusplus
}
#endif
#endif
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
JNIEXPORT jint JNICALL Java_JniCall_add(JNIEnv *, jclass, jint first, jint second) {
printf("print in c : %d + %d = %d \n", first, second, first + second);
return first + second;
}