need info on implementing callback

M

maverick

Hello

I have a native routine , but need to call into java code when i get
an event say a KeyPress .



My native function is like this

JNIEXPORT jint JNICALL Java_MyJava_MyInitialize
(JNIEnv *pEnv, jclass)
{

// Spawn a thread to listen for event
AfxBeginThread( WorkerThread , NULL)

}


UINT WorkerThread(LPVOID)
{
// Need to call a in a java class
}


can someone guide me on the steps needed to accomplish this

I have a vague idea to do this but kinda got lost

I know that In the native routine

1. need to cache the JVM . How do i do this
2. can i cache an object passed so that I can call the method for that
particular object ?
3. Using the cached JVM , create a new JNIEnv object in the worker
thread
4. Call AttachCurrentThread
5. Make the function call

Will be great if I can get some inputs to clarify this
 

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
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top