Hi,
I have written a jni program to call my vc++ dll.
My java program is as below:
//CODE
import java.util.*;
class callVcc
{
native int sum(int i, int j);
static
{
System.loadLibrary("getSum");
}
public static void main(String args[])
{
callVcc sumnum = new callVcc();
int z;
z = sumnum.sum(1,2);
System.out.println("Result::::" + z);
}
}
My vc++ dll is as follows::
// getSum.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <jni.h>
#include "callVcc.h"
#ifdef _MANAGED
#pragma managed(push, off)
#endif
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
JNIEXPORT jint JNICALL Java_callVcc_sum
(JNIEnv * env, jobject jobj, jint x, jint y)
{
return x+y;
}
getSum.def file is as follows::
#ifdef _MANAGED
#pragma managed(pop)
#endif
LIBRARY GETSUM
EXPORTS
sum @1
//CODE
While compiling I am not getting any error ,but while trying to run the java program ,I am getting java.lang.UnsatisfiedLinkError :sum at callVcc.sum<Native method>
at callVcc.main<callVcc.java:15>
Any help would be highly appreciated
Gayatri