Frotty
Frotty

Reputation: 75

LoadLibrary can't find .dll in NetBeans

I trying to load SFmpq.dll via this code

static {
    Native.setProtected(true);
    System.setProperty("jna.library.path",
            new File("lib").getAbsolutePath());
    System.out.println(System.getProperty("jna.library.path"));
    INSTANCE = (SFmpq)   Native.loadLibrary("SFmpq", SFmpq.class);
}

It gets executed, Folder and File exist but I still get this error:

C:\Users\Frotty\Documents\NetBeansProjects\Optimizer\lib Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Unable to load library 'SFmpq': The specified module could not be found.

I gave the code and .dll a friend of mine who imported it into Eclipse and there it worked perfectly fine. Can anyone spot my mistake or how do I import .dlls correctly?

Upvotes: 1

Views: 2223

Answers (2)

Peter Zeller
Peter Zeller

Reputation: 2296

You can get this error if you try to load a 32 bit library on a 64 bit system.

Upvotes: 1

Tim Sparg
Tim Sparg

Reputation: 3304

I've had success with using System.load(...) and System.loadLibrary(..) to load dlls

Upvotes: 0

Related Questions