Step 1: Write the Java Code

        public class HelloWorld {
            public native void greet( );

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

            public static void main (String[ ] args) {
                new HelloWorld().greet( );
            }
        }
 
 

 

Step 2: Compile the Java Code
 

 


Step 3: Create the JNI-style header file

 

Step 4: Implement the Native Method

        // ----------------------
        // filename: Hello1.c
       // ----------------------

        #include <jni.h>
        #include "HelloWorld.h"
        #include <stdio.h>

        JNIEXPORT void JNICALL
        Java_HelloWorld_greet (JNIEnv *env, jobject obj)
        {
             printf("Hello world!\n");
             return;
        }
 
 


Step 5: Create the Shared Library
 


Step 6: Run the Java Program