JNA --简单示例

 

添加jna.jar包

 

//jna的类
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;

 

public class testJNA {
 
 

 public interface CLibrary extends Library {

     //如果需要动态传DLL的名称,可以将下面实例化的语句放到主程序当中
     CLibrary INSTANCE = (CLibrary)Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);   
     void printf(String format, Object... args);   
  }
 
 
 /**
  * @param args
  */
 public static void main(String[] args) {
   
   
     // TODO Auto-generated method stub

     CLibrary.INSTANCE.printf("Hello, World\n");

  
 }

}

 

 

 

posted @ 2012-09-17 15:51  旦旦哥  阅读(224)  评论(0编辑  收藏  举报