UnSatisfiedLinkError -- Very Very Urgent...

Hi,

We are using a third party tool in our application. Our application has to call a function from the third party tool. The particular method is in a dll. We have been provided with the dll.

I tried loading the "dll" by using

1.System.loadLibrary("rlpolk");

and declared the native method.

2.private native void cvina(char inVin[],char outVIN[]);

3. Compiled the Java file

4. Created the header file by using javah.exe command

5. Created C file. I have written the function implementation in the C file.

When I try to compile the c file it throws a error " unable to find include file jni.h"

When I try to execute the java file I get UnSatisfiedLinkError: " Unable to find the method.

Please advise. Its very urgent.

Below is my program.

<CODE>

CallCvina.java

package Janci.CVINA;

public class CallCvina

{

static

{

System.setProperty("java.library.path","C:\\PCCVINA");

System.loadLibrary("rlpolk");

//System.load("C:\\PCCVINA\\rlpolk.dll");

}

String VIN=new String("1C4GP55R4VB238735");

char[] inVin =new char[34];

char[] outVIN=new char[1299];

private native void cvina(char inVin[],char outVIN[]);

public static void main(String args[])

{

CallCvina CC = new CallCvina();

CC.inVin=CC.VIN.toCharArray();

CC.outVIN[0]='\0';

try{

CC.cvina(CC.inVin,CC.outVIN);

}

catch (UnsatisfiedLinkError e)

{

System.err.println("Unable to find cvina function."+ e.getMessage());

}

}

CVINA.h

/* DO NOT EDIT THIS FILE - it is machine generated */

#include <jni.h>

/* Header for class CallCvina */

#ifndef _Included_CallCvina

#define _Included_CallCvina

#ifdef __cplusplus

extern "C" {

#endif

/*

* Class:CallCvina

* Method:cvina

* Signature: ([C[C)V

*/

JNIEXPORT void JNICALL Java_CallCvina_cvina

(JNIEnv *, jobject, jcharArray, jcharArray);

#ifdef __cplusplus

}

#endif

#endif

CVINA.c

#include <jni.h>

#include "CVINA.h"

#include <stdio.h>

JNIEXPORT void JNICALL Java_CallCvina_cvina(JNIEnv *env, jobject obj,jcharArray inVin[], jcharArray outVIN[])

{

printf("Call CVINA Method");

cvina(inVin,outVIN);

return;

}

</CODE>

Thanks,

Janci

[2595 byte] By [JanciVijaya] at [2007-10-3 0:35:54]
# 1

You have your rlpolk.dll third party DLL.

You need to create a JNI wrapper DLL that will do the bridge between JAVA and your third party DLL.

We will call this DLL: wrapperRlpolk.dll

In your Java class you don't specify the java.library.path System property.

You do that when executing the JVM:

java -Djava.library.path=C:\\PCCVINA Janci.CVINA.CallCvina

In your Java class you will load the wrapper DLL and NOT the third party DLL:System.loadLibrary("wrapperRlpolk");

Your JNI header seems not uptodate with the Java class because the JNI function signature should contains the JAVA class package name:JNIEXPORT void JNICALL Java_Janci_CVINA_CallCvina_cvina(JNIEnv *, jobject, jcharArray, jcharArray);

When building your wrapper DLL make sure of linking it with your third party DLL.

Regards

jfbrierea at 2007-7-14 17:29:38 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

>

> 5. Created C file. I have written the function

> implementation in the C file.

> When I try to compile the c file it throws a error "

> unable to find include file jni.h"

>

As noted the java signature does not match the C signature that you are using.

And if the C file does not compile then you do not have a dll to load. So it is pointless to try. It can't find the jni.h file because it isn't in your path (part of the setup needed to build the dll.)

jschella at 2007-7-14 17:29:38 > top of Java-index,Java HotSpot Virtual Machine,Specifications...