UnsatisfiedLinkError In Exported Jar But Not In Eclipse

C

cppaddict

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
 
G

Gordon Beaton

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.

Post the full text of the exception.

I'll assume that C:\WINDOWS is in your PATH...

/gordon
 
C

cppaddict

Thanks for the reply, Gordon.
Post the full text of the exception.

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)
I'll assume that C:\WINDOWS is in your PATH...

Yes, it is.
 
G

Gordon Beaton

Thanks for the reply, Gordon.


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)

From the error message it is clear that the DLL was found and
successfully loaded. The error is that it does not appear to contain
the expected method "open".

Have you compiled the DLL or did it come pre-compiled with jpcap?

Use a tool like dumpbin, depends or quickview to display the actual
contents of the DLL. Confirm that it does contain the method, and that
the symbol name has not been mangled by the compiler.

Do you have different versions of the jpcap library installed on your
system?

/gordon
 
C

cppaddict

From the error message it is clear that the DLL was found and
successfully loaded. The error is that it does not appear to contain
the expected method "open".

I see. But everything is working fine from eclipse... which means
that 2 different DLLs must be getting read, right? Or is there
another explanation?

I verified that C:\WINDOWS is the first folder on my path that
contains a file called "jpcap.dll".
Do you have different versions of the jpcap library installed on your
system?

This is possible, and seems the most likely explanation. So how can I
figure out what DLL eclipse is loading, since that is obviously the
correct one?

Thanks for your help,
cpp
 
C

cppaddict

Someone else helped me solve this. Here are the results for
posterity:

The loadLibrary function look in the home directory, in the java
-Djava.library.path variable and in the path.

I have an old version of the DLL in java.library.path.

DOH!

Thanks for your help Gordon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top