Subject : Java Native Interface ±¸Çö ¿¹

Solution Description:
=====================


   ´ÙÀ½Àº °£´ÜÇÑ Native Method¸¦ ±¸ÇöÇÏ´Â °£´ÜÇÑ ¿¹¸¦ ±â¼úÇÏ¿´´Ù.

   - java source edit


    . HelloWorld Class Á¤ÀÇ

     class HelloWorld {
         public native void displayHelloWorld();

         static {
             System.loadLibrary("hello");
         }  
     }

    . Main Class Á¤ÀÇ

     class Main {
         public static void main(String[] args) {
             new HelloWorld().displayHelloWorld();
         }
     }    
 
 
   - Compile the Java Code

   - Create the .h File

    . javah -jni HelloWorld

   - Native code edit

    . Native Code ¿¹

     #include 
     #include "HelloWorld.h"
     #include 

     JNIEXPORT void JNICALL
     Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
     {
       printf("Hello world!\n");
       return;
     }
~
   - Create a Shared Library

    cc -G -I/usr/local/java/include -I/usr/local/java/include/solaris \
    HelloWorldImp.c -o libhello.so

   - ½ÇÇà
----------------------------------------------------------------------------

Revision History

ÀÛ¼ºÀÏÀÚ : 97.07.19
ÀÛ¼ºÀÚ : À̹ÎÈ£

¼öÁ¤ÀÏÀÚ :
¼öÁ¤ÀÚ :