hi guys im fed up with jni couldnt even execute a simple helloworld program.. here is what i did as per the instruction given in a JNI book..
STEP 1:
Creating HelloWorld.java
compile HelloWorld.java to get HelloWorld.class
STEP 2
Creating a jni style header
command: javah -jni HelloWorld will generate a header file HelloWorld.h
STEP 3:
Creating dll and lib files
compile with file along with the header in Visual Studio in a dll project will generate dll files#include <jni.h> #include <stdio.h> #include "HelloWorld.h" JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj) { printf("Hello World!\n"); return; } int main(int argc, char **argv) { // dummy return 0; }
STEP 4
now i ve created a java class file header file and the library HelloWorld.dll
when i execute the java HelloWorld.class it throws the the error
Exception in thread "main" java.lang.UnsatisfiedLinkError: no HelloWorld.dll in
java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at HelloWorld.<clinit>(HelloWorld.java:9)
Could not find the main class: HelloWorld. Program will exit.
guys please help me i dont know how to fix and i followed lot of other tutorials and i get the same error