日期:2014-05-20  浏览次数:20683 次

请问C调用JAVA的怪问题。
1》
执行的时候出现:
#   An   unexpected   error   has   been   detected   by   HotSpot   Virtual   Machine:
#
#     SIGSEGV   (0xb)   at   pc=0x0804856c,   pid=1613,   tid=3076404928
#
#   Java   VM:   Java   HotSpot(TM)   Client   VM   (1.5.0_11-b03   interpreted   mode)
#   Problematic   frame:
#   C     [transcomm+0x56c]
#
#   An   error   report   file   with   more   information   is   saved   as   hs_err_pid1613.log
#
#   If   you   would   like   to   submit   a   bug   report,   please   visit:
#       http://java.sun.com/webapps/bugreport/crash.jsp
#
已放弃


我的C程序中调用的一个类是在一个jar包中的。但我的C程序中设置了
options[1].optionString   =   classpath;
其中classpath的内容是-Djava.class.path=.:api.jar
api.jar就在执行程序的当前路径。

2》
我的java类中的参数是String的。我的C程序中传过来的是const   char   *
我用jstring   sbatchid =   (*env)-> NewString(env,   (const   jchar   *)batchid,   strlen(batchid));
就core   dump.去掉这句就没问题,不知道哪里不对。

谢谢。

------解决方案--------------------
必须这样调用吗?如果采用TCP/IP来连接,调用某个函数呢?把结果返回,这样不好吗?
------解决方案--------------------
帮忙顶
------解决方案--------------------
等,是C调用Java,还是Java调用C?

------解决方案--------------------
C调用Java.没写过哦。帮你顶一下。