AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

JNI_CreateJavaVM() fails

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Nov 22, 2006 9:15 pm    Post subject: JNI_CreateJavaVM() fails Reply with quote



Hello,

I try to create a Java virtual machine in a C++
application (Windows XP). I have installed
jdk1.5.0_08 and I am sure, that my application
loads the appropriate jvm.dll. Here is my simple
code, I receive always -1:

....
JavaVMOption options[2];
options[0].optionString = "-Djava.compiler=NONE";
options[1].optionString = "-Djava.class.path=.";

JavaVMInitArgs args;
args.version = JNI_VERSION_1_4;
args.nOptions = 2;
args.options = options;
args.ignoreUnrecognized = JNI_FALSE;
....
response = JNI_CreateJavaVM(&mJvm, (void**)&mEnv, &args);
....

Can you please say me what is wrong?!

Thanks,
Anahita
Back to top
Manfred Rosenboom
Guest





PostPosted: Wed Nov 22, 2006 9:30 pm    Post subject: Re: JNI_CreateJavaVM() fails Reply with quote



IMHO the option -Djava.compiler=NONE is no longer valid.
You can test it by using the line

args.ignoreUnrecognized = JNI_TRUE;

instead of

args.ignoreUnrecognized = JNI_FALSE;
Back to top
Guest






PostPosted: Wed Nov 22, 2006 9:38 pm    Post subject: Re: JNI_CreateJavaVM() fails Reply with quote



a...@dsa-ac.de wrote:
Quote:
Hello,

I try to create a Java virtual machine in a C++
application (Windows XP). I have installed
jdk1.5.0_08 and I am sure, that my application
loads the appropriate jvm.dll. Here is my simple
code, I receive always -1:

...
JavaVMOption options[2];
options[0].optionString = "-Djava.compiler=NONE";
options[1].optionString = "-Djava.class.path=.";

JavaVMInitArgs args;
args.version = JNI_VERSION_1_4;
args.nOptions = 2;
args.options = options;
args.ignoreUnrecognized = JNI_FALSE;
...
response = JNI_CreateJavaVM(&mJvm, (void**)&mEnv, &args);
...

Can you please say me what is wrong?!

Thanks,
Anahita

I don't think more than one JavaVM instance can be created per process.
You can use JNI_GetCreatedJavaVMs to determine if you already have one
created, which you should if you're calling a native function from Java.
Back to top
Guest






PostPosted: Wed Nov 22, 2006 10:12 pm    Post subject: Re: JNI_CreateJavaVM() fails Reply with quote

Hello,

here my actual code after your corrections:

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

JavaVMInitArgs args;
args.version = JNI_VERSION_1_4;
args.nOptions =2;
args.options = options;
args.ignoreUnrecognized = JNI_TRUE;

jsize maxNoOfVMs = 1;
jsize actualNoOfVMs;

response = JNI_GetCreatedJavaVMs(&mJvm, maxNoOfVMs, &actualNoOfVMs);
if (JNI_OK == response && 0 == actualNoOfVMs)
response = JNI_CreateJavaVM(&mJvm, (void**)&mEnv, &args);
....

I get still -1. I could debug in the meantime
depper and I see that the problem is in the 'unlock'
method. It is coming originally from 'HeapAlloc'
method of 'malloc.c' file. Shoud I set the heap size?
Have you any idea?

Thanks,
Anahita
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.