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

 

  if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {

  (void) fprintf(stderr,"Error allocating receive buffer\n");

  tpfree(sendbuf);

  tpterm();

  exit(1);

  }

  (void) strcpy(sendbuf, "0123456789abcdef0123456789abcdef");

  /* Request the service TOUPPER, waiting for a reply */

  ret = tpcall("TOUPPER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);

  if(ret == -1) {

  (void) fprintf(stderr, "Can't send request to service TOUPPER\n");

  (void) fprintf(stderr, "Tperrno = %d\n", tperrno);

  tpfree(sendbuf);

  tpfree(rcvbuf);

  tpterm();

  exit(1);

  }

  (void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);

  /* Free Buffers & Detach from System/T */

  tpfree(sendbuf);

  tpfree(rcvbuf);

  tpterm();

  return;

  }

  #ifdef __cplusplus

  }

  #endif

  #endif

  5.编译.c为.o .so

  gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -I$TUXDIR/include -c -L${TUXDIR}/lib Hello.c

  gcc -shared -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -I$TUXDIR/include -L$TUXDIR/lib  -ltux -lbuft  -lfml -lfml32 -lengine -ldl -lpthread /usr/lib/libcrypt.a -Wl,-soname,libhello.so.1 -o libhello.so.1.0 Hello.o

  cp libhello.so.1.0 libhello.so

  6.ldd libhello.so

  如果看到一下的输出,恭喜!基本OK啦!

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

责任编辑:cyth

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