Here, I am using JNA with Direct Mapping which can improve the performance. A small change is necessary to do this than described in my previous post. This will include only java portion. For other portion, refer to the previous post.
Sample java code:
File: HelloDirectWorld.java
import com.sun.jna.Library;
import com.sun.jna.Native;
public class HelloDirectWorld {
public static native void printHello();
static {
Native.register("useC");
}
static public void main(String argv[]) {
printHello();
}
}
Sample java code:
File: HelloDirectWorld.java
import com.sun.jna.Library;
import com.sun.jna.Native;
public class HelloDirectWorld {
public static native void printHello();
static {
Native.register("useC");
}
static public void main(String argv[]) {
printHello();
}
}
Command used to compile HelloDirectWorld.java:
javac -classpath .:jna-3.2.3.jar HelloDirectWorld.java
Command to run our java program:
java -classpath .:jna-3.2.3.jar HelloDirectWorld
The output will be:
Hello Blog World
Enjoy using JNA.
No comments:
Post a Comment