How to use JNA, a demonstration

How use JNA, a demonstration

JNA

Java Native Access is an extension to Java that allows the use of native APIs by including dynamically library files, DLLs under Windows.

JNA is a simpler alternative to JNI which does not require to generate code for using C functions. To use them, simply include the file that defines them and declare the header of these functions in an interface.
Demonstration

To use the puts function of the C language, which is provided by the msvcrt.dll file in Windows, create the following interface:

package CInterface;

import com.sun.jna.Library;

public interface CInterface extends Library
{
public int puts(String str);
}

We have declared the CInterface interface which is a subclass of J

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

What is 7 + 7 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)