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,.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.