dcsimg
Can't create VM from C++
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ferenc_Habony
Posted On:   Wednesday, June 4, 2003 06:48 AM

I use j2sdk1.4.1_02 and Microsoft Visual C++.NET version 7.0.9466 on Windows XP and I try to create a VM from C++ code like this: JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[1]; args.version = JNI_VERSION_1_4; args.nOptions = 1; options[0].optionString = "-Djava.class.path=C:\dev\eclipse\workspace\JNI_TEST"; args.options = options; args.ignoreUnrecognized = JNI_TRUE; jint res = JNI_CreateJavaVM(&jvm, (void **)&env, &args); My jvm.dll doesn't exist in /bin/classic as stated at SUNs homepage (Frequently Asked Questions JavaTM 2 SDK v1.2 and    More>>

I use j2sdk1.4.1_02 and Microsoft Visual C++.NET version 7.0.9466 on Windows XP and I try to create a VM from C++ code like this:



JavaVM* jvm;

JNIEnv* env;


JavaVMInitArgs args;

JavaVMOption options[1];

args.version = JNI_VERSION_1_4;

args.nOptions = 1;

options[0].optionString = "-Djava.class.path=C:\dev\eclipse\workspace\JNI_TEST";

args.options = options;

args.ignoreUnrecognized = JNI_TRUE;

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




My jvm.dll doesn't exist in /bin/classic as stated at
SUNs homepage (Frequently Asked Questions JavaTM 2 SDK v1.2 and JNI) but in both C:j2sdk1.4.1_02jre inserver and C:j2sdk1.4.1_02jre inclient. Which one should be used???
Currently I link to the jvm.lib because that's the only one the linker doesn't complain about. But I always get -1 as a result of JNI_CreateJavaVM().
I have searched the net for documentation about this but I mostly find old stuff.



Please help
/Ferenc

   <<Less

Re: Can't create VM from C++

Posted By:   Alexander_Krapf  
Posted On:   Tuesday, July 8, 2003 06:47 PM

Ferenc,


In my opinion, you should never link against jvm.lib at all. The right way to do this is to use LoadLibrary to dynamically load the JVM from a configurable location and use the GetProcAddr API to find the invocation interface pointers to use.


We do this in the JunC++ion runtime library and it works reliably across all JVMs since 1.1.7.


The downside of hard-linking against a jvm.lib is that you tie yourself to that one and you also get into deployment issues.


Regards,


Alex

Re: Can't create VM from C++

Posted By:   Mahmut_Ozcan  
Posted On:   Saturday, June 21, 2003 06:04 AM

I take the "jvm.lib" to my working directory then its working. Use jvm.dll under "C:j2sdk1.4.0jreinserver" directory, take it easy... Mahmut Ozcan

Re: Can't create VM from C++

Posted By:   Anonymous  
Posted On:   Wednesday, June 18, 2003 03:17 AM

Have you tried to import a new jvm.lib from the jvm.dll located under /bin/client and compile you jvm against the new imported jvm.lib?

Try this, it may work.

Re: Can't create VM from C++

Posted By:   Ramesh_Gajula  
Posted On:   Friday, June 6, 2003 06:44 PM

Hi Ferenc,

Just checking to see if you had any crack at this?
I ran into similar issue recently. Infact my C++ app was doing fine until now (runtime version 1.2(JRE) which was compiled against JDK 1.2.
However as soon I upgraded my runtime version to 1.3 and (tried 1.4 too) I got these failures on JNI_CreateJavaVM().
About | Sitemap | Contact