I wrote a Java class which accesses a method in the C dll through Jni.
But I am getting the following error in windows.
java.lang.UnsatisfiedLinkError: Server.getNetworkDiagram(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
Guess it is able to load the library.
Also I am building the .dll (for windows) and .so (for linux) from a set of common C files This works with .so file and i do not get any error.
Could you please help me out ?
How do I debug here ?
Thanks, Sudarshan
Not sure whether it is misspelt because it works in linux.
Below are the header file and the Java file.
========
JNI File
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Server */
#ifndef _Included_Server
#define _Included_Server
#ifdef __cplusplus
extern "C" {
#endif
#undef Server_GETNETWORK
#define Server_GETNETWORK 1L
#undef Server_SETLEVEL
#define Server_SETLEVEL 2L
/*
* Class: Server
* Method: getNetworkDiagram
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_Server_getNetworkDiagram
(JNIEnv *, jobject, jstring, jstring, jstring);
/*
* Class: Server
* Method: setLevelQuery
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_Server_setLevelQuery
(JNIEnv *, jobject, jstring, jstring, jstring, jint, jint, jstring);
#ifdef __cplusplus
}
#endif
#endif
=========
Java File
=========
public class Server
{
public native String getNetworkDiagram(String domain, String dest, String secret);
public void test()
{
String domain = "domain1";
String host = "2.2.2.30";
String secret = "test";
System.loadLibrary("libewapi");
String result = this.getNetworkDiagram(domain, host, secret);
}
public static void main(String argv[]) throws Exception
{
Server server = new Server();
server.test();
}
}