Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / November 2006

Tip: Looking for answers? Try searching our database.

JNI_CreateJavaVM() fails

Thread view: 
aa@dsa-ac.de - 22 Nov 2006 15:15 GMT
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
Manfred Rosenboom - 22 Nov 2006 15:30 GMT
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;
santiago538@yahoo.com - 22 Nov 2006 15:38 GMT
a...@dsa-ac.de wrote:
> Hello,
>
[quoted text clipped - 22 lines]
> 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.
aa@dsa-ac.de - 22 Nov 2006 16:12 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.