java.lang.UnsatisfiedLinkError no *****.dll in java.library.path

Viewed 405908

How can I load a custom dll file in my web application? I've tried the following:

  • Copied all required dlls in system32 folder and tried to load one of them in Servlet constructor System.loadLibrary
  • Copied required dlls into tomcat_home/shared/lib and tomcat_home/common/lib

All these dlls are in WEB-INF/lib of the web-application

14 Answers
  1. If you believe that you added a path of native lib to %PATH%, try testing with:

    System.out.println(System.getProperty("java.library.path"))
    

It should show you actually if your dll is on %PATH%

  1. Restart the IDE Idea, which appeared to work for me after I setup the env variable by adding it to the %PATH%

It is simple just write java -XshowSettings:properties on your command line in windows and then paste all the files in the path shown by the java.library.path.

I had the same problem and the error was due to a rename of the dll. It could happen that the library name is also written somewhere inside the dll. When I put back its original name I was able to load using System.loadLibrary

First, you'll want to ensure the directory to your native library is on the java.library.path. See how to do that here. Then, you can call System.loadLibrary(nativeLibraryNameWithoutExtension) - making sure to not include the file extension in the name of your library.

The issue for me was naming:

The library name should begin with "lib..." such as libnative.dll.

So you might think you need to load "libnative": System.loadLibrary("libnative")

But you actually need to load "native": System.loadLibrary("native")

Related