You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

加载dtwainjni32.dll时遇UnsatisfiedLinkError:找不到依赖库

Fixing UnsatisfiedLinkError for DTWAIN JNI Library

When loading the DTWAIN JNI library in Java, the "Can't find dependent libraries" error usually means the main DLL (dtwainjni32.dll) relies on other libraries that aren't accessible to the JVM. Here are practical steps to resolve this:

1. Identify Missing Dependencies

First, pinpoint exactly which libraries are missing using one of these tools:

  • Dependency Walker: Open dtwainjni32.dll with this tool—any missing dependencies will show up with red icons.
  • Visual Studio's dumpbin: Run this command in a VS command prompt to list all required DLLs:
    dumpbin /dependents "C:\Program Files (x86)\Java\jdk1.8.0_361\bin\dtwainjni32.dll"
    
    Note down any DLLs that aren't present on your system or in a reachable path.

2. Match Architecture (32-bit vs 64-bit)

You're using a 32-bit JDK, so every DLL involved (DTWAIN library, its dependencies, scanner drivers) must be 32-bit. 64-bit DLLs won't load in a 32-bit JVM.

  • To verify a DLL's architecture, run:
    dumpbin /headers <path-to-dll> | findstr "machine"
    
    Look for "machine (x86)" to confirm it's 32-bit.

3. Make Dependencies Accessible

Once you have the missing DLLs, get them from the DTWAIN library package or your system, then:

  • Place them in the same folder as dtwainjni32.dll (your JDK's bin directory), or
  • Add their directory to the system PATH (restart your terminal/IDE after modifying this), or
  • Specify the path when launching your Java app:
    java -Djava.library.path="C:\path\to\dtwain-dlls;C:\path\to\other-dependencies" Main
    

4. Install Scanner Drivers and TWAIN Components

The DTWAIN library needs TWAIN/WIA support to communicate with scanners:

  • Install the latest 32-bit TWAIN/WIA drivers for your scanner.
  • Ensure twain_32.dll exists in C:\Windows\SysWOW64 (for 64-bit Windows running 32-bit apps) or C:\Windows\System32 (for 32-bit Windows).

5. Double-Check Library Loading

  • Confirm you're loading the correct DLL: System.loadLibrary("dtwainjni32u") looks for dtwainjni32u.dll. If your file is named dtwainjni32.dll, either rename it or adjust the load call to System.loadLibrary("dtwainjni32").
  • Avoid using debug builds of the DLL—stick to release versions compatible with JDK 1.8.

6. Verify Required Environment Variables

Some DTWAIN setups need environment variables like DTWAIN_DIR pointing to the library's resource folder. Refer to the library's documentation for any such requirements and set them in your system or runtime environment.

内容的提问来源于stack exchange,提问作者Ariel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 04:42:43