Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNI_CreateJavaVM fails on Windows - Very urgent

843829Feb 19 2002 — edited Feb 25 2002
Folks,

I am very much new to the JNI on Windows 2000. For the last two days, I am trying to load JVM into my application. But, could not succeed. Even the samples I got across the net failed. The problem is "JNI_CreateJavaVM" returns -1.

Using Microsoft Visual Studio 6.0, and VC++, I created a project with default settings and used the following sample code and it fails left and right. Please, let me know if I am doing something wrong.

Sample
---------------------------------------------------------------------------------
JNIEnv *env = NULL;

JavaVMInitArgs vm_args;
JavaVMOption options[4];
char a1,a2;
int nbOptions;
jint res = 0;
char classpath,librarypath;

classpath = malloc(1024,sizeof(char));
librarypath= malloc(1024,sizeof(char));

strcpy(classpath, "-Djava.class.path=e:\\jdk1.2.2;e:\\jdk1.2.2\\jre\\lib\\i18n.jar");
strcpy(librarypath, "-Djava.library.path=.;e:\\jdk1.2.2\\jre\\bin;e:\\jdk1.2.2\\jre\\bin\\classic");

options[0].optionString = classpath;
options[1].optionString = librarypath;
options[2].optionString = "-Djava.compiler=NONE";
options[3].optionString = "-verbose:jni";

vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 4;
vm_args.ignoreUnrecognized = JNI_TRUE;

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

I tried with other samples also. But, the result is same. JNI_CreateJavaVM returns -1.

If possible, please respond to klokesh@hotmail.com also


Thanks,
Lokesh
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2002
Added on Feb 19 2002
3 comments
796 views