Urgent help -> C++ calling Java codes

M

muhammad.hamdan

Hello,

I have 2 VC++ codes calling Java functions. An application loads these
VC++ dll files. When the application invokes the first VC++ dll , I
initialize and create the JVM using the JNI_CreateJavaVM(&jvm, (void**)

&env,&vm_args) funtion. This works fine and am able to perform all the
operations.
I destroy the JVM when the application is closed.


The problem arises when the application tries to load my other VC++
dll. The second initialise which also has a JNI_CreateJavaVM(&jvm,
(void**) &env,&vm_args) function fails as this returns a -1.


Is there anyway I can have both my dll functioning at the same time?


The thought of destroying JVM after every operation and not leaving it
open till the application closes crossed my mind, even though
performance will be an issue, but that also wouldnt solve the problem
because the application is multi-threaded. So when the first code is
being executed, if someone calls the second one it will fail because
the init fails. Also since it is a known bug that we cannot destroy and

create a VM in the same process, am not able to do that.


Say I make the JNI_CreateJavaVM() in the first dll and I always make
sure that this is initialized first, is there anyway I can do a
(jvm)->AttachThread() to the first one that gets created? and also get
the JNIenv * value from that dll?


Any help would be appreciated. Thanks


Ham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top