Hai friends
I am trying to call the Functionality from C program to
Java Program using JNI
The C program is like
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
Java Program is
class HelloWorld
{
public native void displayHelloWorld();
static
{
System.loadLibrary("hello");
}
public static void main(
String[] args)
{
new HelloWorld().displayHelloWorld();
}
}
I compiled java program using this
javac HelloWorld.java
and i made it as .h file using
javah -jni HelloWorld
Everything is fine but when i am trying to run the java program like this
java HelloWorld
It is saying exception
Exception is
java.lang.UnsatisfiedLinkError: no hello in shared library path
at java.lang.Runtime.loadLibrary(Runtime.java)
at java.lang.System.loadLibrary(System.java)
at
at java.lang.Thread.init(Thread.java)
What shall i do to get the output
Please give me some suggestions
Thanksinadvance
Yours
Rajesh Kumar