N
naleiden
Is it possible to call native methods in a Java program which has
been started with the invocation API, where the navive methods are
implemented in the same C program that started the Java, i.e.:
/////////////////
// C Code //
/////////////////
// start JVM from C
void do_java_work () {
JNI_CreateJavaVM(&jvm, &env, &vm_args);
jclass cls = env->FindClass("Main");
jmethodID mid = env->GetStaticMethodID(cls, "test", "()Z");
env->CallStaticVoidMethod(cls, mid, 0);
...
}
JNIEXPORT jboolean JNICALL Java_doSomething (JNIEnv *env, jobject obj)
{
...
}
// End C code..
/////////////////////
// Java Code //
/////////////////////
public class Main {
public static void test (String args[]) {
doSomething();
}
public native boolean doSomething ();
}
// End Java Code
I know this will not work as currently coded, but can anyone tell me
how to do it, or how to do something equivalent?
Thanks,
-Nick
been started with the invocation API, where the navive methods are
implemented in the same C program that started the Java, i.e.:
/////////////////
// C Code //
/////////////////
// start JVM from C
void do_java_work () {
JNI_CreateJavaVM(&jvm, &env, &vm_args);
jclass cls = env->FindClass("Main");
jmethodID mid = env->GetStaticMethodID(cls, "test", "()Z");
env->CallStaticVoidMethod(cls, mid, 0);
...
}
JNIEXPORT jboolean JNICALL Java_doSomething (JNIEnv *env, jobject obj)
{
...
}
// End C code..
/////////////////////
// Java Code //
/////////////////////
public class Main {
public static void test (String args[]) {
doSomething();
}
public native boolean doSomething ();
}
// End Java Code
I know this will not work as currently coded, but can anyone tell me
how to do it, or how to do something equivalent?
Thanks,
-Nick