Problem accessing a DLL file from a Java program through JNA

I have a dll file and I'm trying to call its functions through a Java program through JNA

But the problem is that it cannot find my DLL file and throws the following exception:

java.lang.UnsatisfiedLinkError: Unable to load library 'UsbDll': The specified module could not be found.

at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
at com.sun.jna.Native.register(Native.java:1018)
at com.MainClass.<clinit>(MainClass.java:15)
Exception in thread "main"  

Below is my program:

package com;

import com.sun.jna.Native

public class MainClass {

    static {
        Native.register("UsbDll");
    }

public native int method();

    public static void main(String[] args) {
    }
}

My dll file name is UsbDll.dll , and my operating system is Windows.

==================================================== ==================================================== ============

The location of my dll file is "c: \ UsbDll.dll"

When I placed another DLL file in the same place, JNA placed it, so I think the problem is only with my "UsbDll.dll" file.

When I tried to load both DLL files (UsbDll.dll and another dll) with the following command

System.load("c:\\UsbDll.dll");
System.load("c:\\another.dll");

"another.dll" , "UsbDll.dll" :

java.lang.UnsatisfiedLinkError: C:\UsbDll.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.MainClass.<clinit>(MainClass.java:16)

Exception in thread "main" 

Q1. , . DLL, , .

, ? , , ?

================================================================================================ ================

Dependency Walker UsbDll.dll, .

WER.DLL ( WINNM.DLL, c:\windows\system32)

IESHIMS.DLL ( WINNM.DLL, c:\windows\system32)

WDAPI920.DLL ( usbDll.dll)

Q1. WINNM.DLL system32, dll. dll 2 dll (WER.DLL IESHIMS.DLL), , , WINNM.DLL?

Q2. googled WDAPI920.dll( UsbDll.dll), . , . , ? ? , , dll (UsbDll.dll), - dll (UsbDll.dll) ?

+5
2

DLL , LD_LIBRARY_PATH (. env), , JNA, .

0

All Articles