Start New Discussion within our Software Development Community

I have confused to use Java Native Interface with dll file (by c++)..
To get the squired value of a number which will be given by user...

this is my class file...which also should be converted as header file for c++ file (dll file preparing...)

class First
public static native int squired();
public static void main(String[] args) 
System.out.print("Enter the Number...");
    int y;
    System.out.println("Squired value is:"+squired());
catch (IOException e)

this file is First.class (with First.h also)...

and this is my c++ coding for the dll file "First.dll"....

#include "jni.h"
#include "jni_md.h"
#include <stdio.h>
#include <math.h>
#include "First.h"
Java_First_squired(JNIEnv *env,jobject obj,jint x,jint y)
return y;

No compiling errors were occurred when preparing dll file and First.class file...
But I have received a run time error follows...

 "java.lang.UnsatisfiedLinkError" this message told that something is wrong with the command..."System.out.println("Squired value is:"+squired());"

I am using Visual C++ to create DLL File and JDK 1.6.0 to write java Programs...
Actually what is happened...? I have already checked the path of dll file and Main Class file(First.class)....

Please correct this coding...and tel me how i can use DLL function to give squired value of the number which will be given by user through Java Program...

This article has been dead for over six months. Start a new discussion instead.