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...)

import java.io.IOException;
class First
{
public static native int squired();
public static void main(String[] args) 
{
System.out.print("Enter the Number...");
try 
    {
    int x=System.in.read();
    int y;
    System.out.println("Squired value is:"+squired());
    }
catch (IOException e)
    {
    System.out.println("Error");
    }
}
static 
    {
    System.loadLibrary("First");
    }
}

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"
JNIEXPORT int JNICALL
Java_First_squired(JNIEnv *env,jobject obj,jint x,jint y)
{
y=x*x;
return y;
}

No compiling errors were occurred when preparing dll file and First.class file...
But I have received a run time error message...as 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...

Look at method signatures.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.