欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JNA

程序员文章站 2022-07-10 15:24:56
...

JAVA NATIVE ACCESS

 

 

下载: http://java.net/projects/jna/downloads/download/3.2.7/jna.jar, platform.jar

API:  http://jna.java.net/javadoc/overview-summary.html

 

 

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;

public class Test {
	public interface CLibrary extends Library {
		CLibrary INSTANCE = (CLibrary) Native.loadLibrary(
				(Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);

		void printf(String format, Object... args);
	}

	public static void main(String[] args) {
		CLibrary.INSTANCE.printf("Hello, World\n");
		for (int i = 0; i < args.length; i++) {
			CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]);
		}
	}
}

上一篇: jna使用入门

下一篇: JNA