dcsimg
Java calling C/C++ and back (asynchronously)
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kid_Kosta
Posted On:   Friday, June 2, 2006 07:44 AM

Hi everybody!, i have the following issue. I have an API in a dll wich allows you to register functions (in C) which will be called when some event occurs. I have to register a Java function so i hava a native method from wich i can access this dll and register another C function into the API, which will call the desired Java method. The problem is that i can get back to Java from within the native method, but i can't get to access from the C callback function which is called by the API asynchronously. What i'm doing is trying to instanciate another JVM from the C callback function, but i can't. Is this the right way to go? Should i try something different? Thanks!    More>>

Hi everybody!, i have the following issue.



I have an API in a dll wich allows you to register functions (in C) which will be called when some event occurs.
I have to register a Java function so i hava a native method from wich i can access this dll and register another C function into the API, which will call the desired Java method.



The problem is that i can get back to Java from within the native method, but i can't get to access from the C callback function which is called by the API asynchronously. What i'm doing is trying to instanciate another JVM from the C callback function, but i can't.



Is this the right way to go? Should i try something different?



Thanks!


   <<Less

Re: Java calling C/C++ and back (asynchronously)

Posted By:   Anonymous  
Posted On:   Tuesday, July 11, 2006 03:18 PM

Each created JVM must be in a different/independent process. If you really want to do that, you must first, create a process with _beginthread (or something like that), and in the new thread you must call (*JavaVM).AttachCurrentThread before calling the method you want to execute.

Re: Java calling C/C++ and back (asynchronously)

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, June 10, 2006 05:41 PM

Sounds like kind of expensive overhead, to create a whole new JVM each time you want to just call a function? Maybe you want to pass messages back and forth over a socket with a protocol?
About | Sitemap | Contact