Brian Knoblauch
Brian Knoblauch

Reputation: 21409

What's the trick to get JNA to interface with 3rd party DLLs?

I'm getting the following error when trying to interface with a Magtek 32-bit DLL.

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Unable to load library 'MCPAPI': The specified module could not be found.

I have no problem interfacing with user32.dll in the same code (just tweaking the DLL name and interface). Seems to indicate that the DLL can't be found, but it's most definitely in my jna.library.path. I've even gone as far as dumping it into the Windows system directory, next to user32, without success.

What am I missing here?

Upvotes: 1

Views: 1311

Answers (3)

technomage
technomage

Reputation: 10069

jna.library.path will only influence loading of libraries directly referenced. Dependent libraries must be found either in the same directory as the explicitly loaded one, or in PATH.

For your example to work, MCPAPI must be in either jna.library.path or PATH, and its dependent libraries must be either in the same directory or in PATH.

Upvotes: 1

buch11
buch11

Reputation: 882

try using System.load(path\to\library) instead System.loadLibrary().

Upvotes: 0

Esben Skov Pedersen
Esben Skov Pedersen

Reputation: 4517

If you run a 64bit jvm you cannot load 32bit dll's. If thats the case, install 32bit jvm

Upvotes: 0

Related Questions