Home > Article > Computer Tutorials > Solve the problem of JAVA calling DLL
MYaction(myinfo);
The general process is like this; if you use ontology, use this method
}
When calling, initialize first:
MYinfo.ByReference myinfo = new MYinfo.ByReference(); //This is the variable you want to pass in as a parameter
transfer:
MYInterface.INSTANCE. . . . Write a MYinfo class in java
public static class MYinfo extends Structure {
public byte[] sType = new byte[16];
public int nVersion;
public static class ByReference extends FACTORY_INFO
implements Structure.ByReference{}//If used as a parameter, this method is used
public static class ByValue extends FACTORY_INFO
implements Structure.ByValue{}//
The NDK comes with the simplest sample, which returns a string from JNI to Java. This is how it is used:
#include
#include
/* This is a trivial JNI example where we use a native method
* to return a new VM String. See the corresponding Java source
* file located at:
*
* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
*/
jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
The above is the detailed content of Solve the problem of JAVA calling DLL. For more information, please follow other related articles on the PHP Chinese website!