Home  >  Article  >  Computer Tutorials  >  Solve the problem of JAVA calling DLL

Solve the problem of JAVA calling DLL

PHPz
PHPzforward
2024-01-24 08:06:05761browse

Solve the problem of JAVA calling DLL

About JAVA calling DLL issues

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{}//

How to use String type in JNI

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!

Statement:
This article is reproduced at:docexcel.net. If there is any infringement, please contact admin@php.cn delete