jni中为什么找不到java类

火鸟33 系统架构师  2005-12-19 02:47:30

#include "stdafx.h"
#include <jni.h>

JavaVM *jvm;

main() {
int res;
JavaVM *jvm;
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[4];
vm_args.version = JNI_VERSION_1_4;
/*设置初始化参数*/
options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
options[1].optionString = "-Djava.class.path=D:\workspace\C2C"; /* user classes */
options[2].optionString = "-Djava.library.path=D:\mom\activemq-3.2\lib"; /* set native library path */
options[3].optionString = "-verbose:jni"; /* print JNI-related messages */

vm_args.nOptions = 4;
vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_TRUE;
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
exit(1);
}
jobject obj;
jclass cls = (*env).FindClass("c2c/jms/JMSQueueSend");
if (cls == 0) {
fprintf(stderr, " Can't find class\n");
exit(0);
}

jmethodID mid;
mid=(*env).GetMethodID(cls,"CreateSession"," (I)Z; ");
jobject msg = (*env).CallStaticObjectMethod(cls, mid);
(*env).CallStaticVoidMethod( cls, mid, 1);
(*jvm).DestroyJavaVM();
fprintf(stdout, "Java VM destory.\n");

}

老是找不到类,但我路径都设置好了,为什么?
...全文
96 点赞 收藏 2
写回复
2 条回复
火鸟33 2005年12月20日
回复 点赞
火鸟33 2005年12月19日
jdk 5.0
回复 点赞
发动态
发帖子
Java SE
创建于2007-09-28

3.4w+

社区成员

30.7w+

社区内容

Java 2 Standard Edition
社区公告
暂无公告