# JNA 메뉴얼에 있는 내용 ```c ////////////////////////////////////////////////////////////////////////// /// /// 접속 상태 메세지 전송 요청 CALLBACK /// /// 접속태 메세지 핸들. /// 사용자 정의 Param ////////////////////////////////////////////////////////////////////////// EXTERN_C INTEROPLIB_API void W4NVMS_SetCBMessageHandle(LPMESSAGEHANDLER fMessageHandle, LPVOID pParam) ``` void* = LPVOID - [Passing a Java class into a void* parameter with JNA](http://stackoverflow.com/questions/4100990/passing-a-java-class-into-a-void-parameter-with-jna) cpp 샘플소스에서 아래와 같이 넘긴다. ```cpp W4NVMS_SetCBMessageHandle(MessageCallBack, this); ``` ```java myClass myObj = new myClass(); myObj.x = 1; myObj.y = 2; Pointer myPointer = myObj.getPointer(); ``` wireshark 로 패킷 비교 ![](https://goo.gl/ASXIji) ![](https://goo.gl/eLLpRQ) ## JNA 사용 JNA 라이브러리를 사용한다. lib 폴더에 jna-4.2.2.jar 파일을 추가한다. ![](https://goo.gl/JeNVMK) Java Build Path → Libraries 에서 jar 를 추가한다. ![](https://goo.gl/5JZYx7) dll을 사용할 인터페이스를 만든다. ```java import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; public interface CHelloWorld extends Library{ CHelloWorld INSTANCE = (CHelloWorld) Native.loadLibrary((Platform.isWindows() ? "com_test_HelloWorld" : "c"), CHelloWorld.class); } ``` main 메소드를 작성한다. ```java public class main { public static void main(String[] args) { CHelloWorld.INSTANCE.print(); } } ``` 실행하면 에러가 발생한다. ``` Unable to load library 'com_test_HelloWorld': Native library (win32-x86/com_test_HelloWorld.dll) not found in resource path ``` bin 폴더에 사용할 dll 파일을 위치한다. 에러 발생 ``` Error looking up function 'print': 지정된 프로시저를 찾을 수 없습니다. ```