4.编写对应的C文件,我一般直接拷贝一个.h文件为.c,之后修改,感觉比较不会出错
#include <stdio.h>
#include "atmi.h" /* TUXEDO Header File */
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Hello */
#ifndef _Included_Hello
#define _Included_Hello
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: Hello
* Method: SayHello
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_Hello_SayHello
(JNIEnv * env, jobject arg)
{
char *sendbuf, *rcvbuf;
long sendlen, rcvlen;
int ret;
printf("THIS IS JNI Say Hello\n");
/* Attach to System/T as a Client Process */
if (tpinit((TPINIT *) NULL) == -1) {
(void) fprintf(stderr, "Tpinit failed\n");
exit(1);
}
sendlen = 32;
/* Allocate STRING buffers for the request and the reply */
if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}
责任编辑:cyth