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
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