Kjeld Perquin
Kjeld Perquin

Reputation: 121

Can't load a .dll with System.load(path);

I made a Java OCR program using the AspriseOCR. It requires a .dll called AspriseOCR.dll, I copied the dll to C:/Windows/System32/ But when I use

System.load("C:/Windows/System32/AspriseOCR.dll");  

I still get a UnsatisfiedLinkError.

I've spent the last 2 days searching for a solution to my problem, but I couldn't find anything that works.


Okay everyone, it works now. Turns out I also had to make a 32-bit version! If anyone ever needs help with the OCR Engine from Asprise, pm and I'll try to help you!

Upvotes: 2

Views: 6878

Answers (1)

Alden
Alden

Reputation: 837

To load libraries, such as DLLs, you should use

    System.loadLibrary("libname");

Where "libname" is the name of the library. You do not include the extension of the file it is stored in, or the full path to the file. For your case, you would probably call

    System.loadLibrary("AspriseOCR");

to load the library you are using.

Because loadLibrary takes a library name for an argument, not a file, you must be careful where you place the .dll. Normally, you could include it in the working directory of the application, or in a native folder such as System32. If you must put it somewhere else, be sure to appropriately set java.libary.path. For example, if the .dll is in the folder "libraries", you should launch java with the argument

    -Djava.library.path=libraries

Upvotes: 4

Related Questions