By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

java.lang.UnsatisfiedLinkError

P: 3
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
Aug 8 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
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
Have you tried to explicitly set the "library.path" system property? Obviously
your library can't be found now. Add a -Dlibrary.path=/path/to/you/lib.dll to
java's command line

kind regards,

Jos
Aug 8 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.