UnsatisfiedLinkError in dynamically loaded class
I have a class which uses some native methods. It works fine when I build it into the jar file with my entire application.
I would like to make this class part of another jar file, and dynamically load the class when it is needed (using a URLClassLoader derivative). Doing it this way, the class is loaded, but when I reference the first native method, I get the UnsatisfiedLinkError.
I am calling System.loadLibrary(dllname), and it appears to be succesful (no exceptions thrown). I can even step into the class and debug it. And as I said, this all works fine when all classes are in the same jar. Any ideas what the problem may be? Thanks....
[674 byte] By [
ryanmicj] at [2007-9-26 3:11:23]

No, none of the pacakges or class names changed. Just how they were built into jars.Could it be some sort of weird security issue? I've been messing with policy files, but that doesn't seem to help...Thanks for the reply
How are you using the URLClassLoader? Loading from an HTTP server from another machine? Using Applet?...
Is it possible that when you got the error, it was actually loading another copy of your dll or so file with the same name? Do a search or find to see if you have another copy of dll or so (older version) hanging around.
yilin at 2007-6-29 11:18:46 >

No, there are no other copies anywhere. I use the URL class loader to load a jar file from the local machine. The URL looks something like this:
"file:///c:\installdir\dynload.jar"
If there was another copy of the dll, wouldn't it have the same problem when all class files were in the same jar? Thanks again...
Loading native lib is probably similar to loading class in the sense that the loading class and the caller class must share the same class loader. Since your caller is loaded by the default loader, the native class is by the URLClassLoader. Do a quick test: move that loadLibrary() call to your main class instead of the current class.
yilin at 2007-6-29 11:18:47 >
