Results 1 to 3 of 3
Thread: UnsatisfiedLinkError using JNI
- 07-14-2011, 08:43 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 2
- Rep Power
- 0
UnsatisfiedLinkError using JNI
Hi,
I have created a simple JNI Java and c++ classes. The code looks as below. I was able to compile the code without errors. But when I'm trying to run the java class I get the UnsatisfiedLinkError error. I have the necessary dll file in the same location as the Java class file. Please help
Error:
C:\foo>java JNIFoo
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\foo\foo.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1732)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at JNIFoo.<clinit>(JNIFoo.java:5)
Could not find the main class: JNIFoo. Program will exit.
Even java -Djava.library.path=C:\foo JNIFoo doesnt help
Java class:
public class JNIFoo {
public native String nativeFoo();
static {
System.loadLibrary("foo");
}
public void print () {
String str = nativeFoo();
System.out.println(str);
}
public static void main(String[] args) {
(new JNIFoo()).print();
return;
}
}
C++ class: (Compiled in Visual Studio 2008)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jni.h"
#include "JNIFoo.h"
JNIEXPORT jstring JNICALL Java_JNIFoo_nativeFoo (JNIEnv *env, jobject obj)
{
jstring ret = 0;
char *buf = (char*)malloc(10);
strcpy(buf, "From Native");
jstring jstrBuf = env->NewStringUTF(buf);
return jstrBuf;
}
- 07-14-2011, 09:10 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
Double posted. Reply to advanced Java.
- 07-14-2011, 09:21 AM #3
Similar Threads
-
UnsatisfiedLinkError on dll load
By Bharath_M in forum Advanced JavaReplies: 8Last Post: 04-11-2011, 11:23 AM -
UnsatisfiedLinkError
By leepan2008 in forum Advanced JavaReplies: 4Last Post: 01-07-2011, 04:40 AM -
JNI: ava.lang.UnsatisfiedLinkError
By tecno40 in forum Java AppletsReplies: 0Last Post: 11-19-2010, 11:59 PM -
UnsatisfiedLinkError
By Hussain Ali in forum EclipseReplies: 2Last Post: 04-11-2010, 07:59 AM -
UnsatisfiedLinkError: lob_createTemporary
By Nauman in forum JDBCReplies: 0Last Post: 08-12-2007, 03:23 PM


LinkBack URL
About LinkBacks

Bookmarks