UnsatisfiedLinkError In Exported Jar But Not in Eclipse.
My application, which depends on a native DLL located in C:\WINDOWS,
is running fine in eclipse. However, if I export the jar and then run
it on the command line, I get an UnsatisfiedLinkError on the native
call.
The strange thing is I never told eclipse where to find the DLL (it
just automatically found it WINDOWS), so I can't figure out why the
command line java is not finding it.....
Any ideas?
Thanks,
cpp
Eclipse knows where to locate it because it is probably in the PATH of your Windows. Maybe you are overriding your PATH variable in the command line program. To debug it, run prompt %PATH% before the java command. Check whether C:/WINDOWS is there.
> Eclipse knows where to locate it because it is
> probably in the PATH of your Windows. Maybe you are
> overriding your PATH variable in the command line
> program. To debug it, run prompt %PATH%
> before the java command. Check whether C:/WINDOWS is
> there.
Daniel, I typed at the cmdline:
prompt %PATH% java
This output contained the path to the dll (C:\WINDOWS), but I wasn't sure if that was the test you meant.
Can you clarify?
Thanks.
It means that C:/WINDOWS is in your path. This is the way eclipse found it.You said that you are getting the error on the native call. Does it means that the System.loadLibrary() succeeded?Could you post the exact error?Daniel
> It means that C:/WINDOWS is in your path. This is the
> way eclipse found it.
> You said that you are getting the error on the native
> call. Does it means that the System.loadLibrary()
> succeeded?
> Could you post the exact error?
So it appears that the dll is actually loading, but that there is a problem with a method call:
PacketCapture: loading native library jpcap.. ok
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: open
at net.sourceforge.jpcap.capture.PacketCapture.open(Native Method)
at net.sourceforge.jpcap.capture.PacketCapture.open(PacketCapture.java:6
3)
at network.Sniffer.startSniff(Sniffer.java:132)
at network.Sniffer.run(Sniffer.java:170)
at java.lang.Thread.run(Unknown Source)
This is strange because, as far as I can tell, this means that eclipse and java must be loading different DLLs, right? I certainly may have installed different versions at different times, but there is only one jpcap.dll in my C:\WINDOWS folder, so how can they be loading different ones?
Or is there another explanation?
The loadLibrary function look in the home directory, in the java -Djava.library.path variable and in the path. Maybe the Eclipse home directory contains a version of this dll or the command line home dir contains it. Also it is possible that you have it in the -Djava.library.path on the Eclipse or the command line.
Daniel
> The loadLibrary function look in the home directory,
> in the java -Djava.library.path variable and in the
> path. Maybe the Eclipse home directory contains a
> version of this dll or the command line home dir
> contains it. Also it is possible that you have it in
> the -Djava.library.path on the Eclipse or the command
> line.
>
> Daniel
Thank you so so so much.
There was an old version in here:
C:\Program Files\Java\jre1.5.0_06\bin
For future reference, how do determine java.library.path? I basically just guessed to find that....
Anyway, I really appreciate your help.
hqd
> For future reference, how do determine java.library.path? I basically just guessed to find that....It is a System property value.