Reputation: 23
Hi guys i have tried all the solutions like java -Djava.library.path=. demo adding the dll path to PATH java -Djava.library.path=c:\JNI\demo.dll demo
But still the above error.
Here is my java code..
class demo
{
public native void printline();
public static void main(String[]args)
{
new demo().printline();
}
}
Here is my c code...
#include<stdio.h>
#include<jni.h>
#include "demo.h"
JNIEXPORT void JNICALL Java_demo_printline(JNIEnv *a, jobject b)
{
printf("Hello wrold!!!");
return;
}
Steps for compiling and running,
Am i going wrong somewhere?
can someone please help me out,.
Upvotes: 2
Views: 846
Reputation: 132
Try Run-Time Loading of the dll file within the java code in a static block like:
static
{
System.loadLibrary("demo");
}
should give you the output.
Moreover make sure that dll file generated is x32 or x64 according to the gcc compiler in use.
Upvotes: 1
Reputation: 3894
looking for "JNI hello world" (or many other terms, possibly), would have given you the answer.
for example:
http://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html
java.library.path
Upvotes: 0