Unable to create JVM

Hi !

In my project, i need to call a java method from C code using JNI.

Here is the Java code:

publicclass Prog{

publicstaticvoid main(String args[]){

System.out.println("Hello Java Native"+args[0]);

}

}

And C code:

#include <jni.h>

void destroy (JNIEnv *env,JavaVM *jvm,char *str){.....}

main(){

JNIEnv *env;

JavaVM *jvm;

JavaVMInitArgs vm_args;

JavaVMOption options[3];

....................

options[0].optionString ="-Djava.compiler=NONE";

options[1].optionString ="-Djava.class.path=.";

options[2].optionString ="-verbose:jni";

memset (&vm_args,0,sizeof(vm_args));

vm_args.version = JNI_VERSION_1_4;

vm_args.nOptions = 3;

vm_args.ignoreUnrecognized = JNI_TRUE;

vm_args.options = options;

/* Create Java VM */

res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);

if(res<0){

fprintf(stderr,"Can't create Java VM\n");

printf("%d",res);

exit(1);

}

................................................

(*env) -> CallStaticVoidMethod(env,cls,mid,args);

(*jvm) -> DestroyJavaVM(jvm);

}

I think the code is alright.But when i run it , it tells me "Can't create Java VM".I guess there are some problems with Path or CLASSPATH? And i copy a (jre\bin\client)jvm.dll. Is there something wrong?

Thank you for your help.丠

[2181 byte] By [Taurenla] at [2007-10-3 0:40:35]
# 1
Do NOT copy jvm.dll into your executable folder.instead simply set the Path environment variable appropriately before the executionset Path=C:\Program Files\Java\jre1.5.0_07\bin\client;%Path%yourExecutable.exeRegards
jfbrierea at 2007-7-14 17:34:46 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Thank you : )
Taurenla at 2007-7-14 17:34:46 > top of Java-index,Java HotSpot Virtual Machine,Specifications...