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

Solve the problem of JAVA calling DLL

PHPz
Release: 2024-01-24 08:06:05
forward
809 people have browsed it

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!

source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template