Situation: I have a dll which implemented JNI,I want to call the methods in it from a Cpp application.
Current Status:
According to my understanding, a dll which implemented JNI actually has nothing to do with JAVA, for example:
In Test.java, I wrote
public native int Add(int a,int b);
And realized it with Cpp In TestDll.Cpp
JNIEXPORT jint JNICALL Java_SomeNamespace_Add(JNIEnv* _Env, jobject _Object, jint a, jint b)
{
return a+b;
}
I think that such a program has nothing to do with JVM, the jint structure seems have been fully defined in jni.h.
So, I wonder if it's possible to call Java_SomeNamespace_Add
directly without creating a VM from a Cpp application, if it do is possible,:
- What should the `JNIEnv*` and the `jobject` in the parameter list be?
- How can i convert a `jint` variable to a standard `int` variable?
- How can i convert a `jstring` variable to a standard `string` variable without using `_Env->FindClass("Ljava/lang/String;")` and a bunch of following code?
env
pointer and/or the receiver object or possible parameter objects? I don't think you can generalize this from your test function. – user2543253