Java通过JNI调用Tuxedo方法
来源:优易学  2010-1-11 11:30:22   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  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);

  }

上一页  [1] [2] [3] [4] 下一页

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
热门课程培训