【问题标题】:java.lang.UnsatisfiedLinkError exception when using TESSERACT API in Java在 Java 中使用 TESSERACT API 时出现 java.lang.UnsatisfiedLinkError 异常
【发布时间】:2015-06-10 21:12:46
【问题描述】:

我正在尝试将 Java JNA 包装器用于 Tesseract OCR API,但我不断收到 java.lang.UnsatisfiedLinkError 异常

我从http://sourceforge.net/projects/tess4j/下载了最新版本

我确定我使用的是 32 位 JVM。以下是异常跟踪。

线程“main”java.lang.UnsatisfiedLinkError 中的异常:找不到指定的模块。

在 com.sun.jna.Native.open(本地方法)
在 com.sun.jna.Native.open(Native.java:1759)
在 com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
在 com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
在 com.sun.jna.Library$Handler.(Library.java:147)
在 com.sun.jna.Native.loadLibrary(Native.java:412)
在 com.sun.jna.Native.loadLibrary(Native.java:391)
在 net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:79)
在 net.sourceforge.tess4j.TessAPI.(TessAPI.java:40)
在 net.sourceforge.tess4j.Tesseract.init(Tesseract.java:360)
在 net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:273)
在 net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:205)
在 net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:189)
在 net.sourceforge.tess4j.Main.main(Main.java:12)

我在做什么明显的错误?

我使用了http://tess4j.sourceforge.net/codesample.html的示例代码

package net.sourceforge.tess4j.example;

import java.io.File;
import net.sourceforge.tess4j.*;

public class TesseractExample {

    public static void main(String[] args) {
        File imageFile = new File("eurotext.tif");
        Tesseract instance = Tesseract.getInstance();  // JNA Interface Mapping
        // Tesseract1 instance = new Tesseract1(); // JNA Direct Mapping

        try {
            String result = instance.doOCR(imageFile);
            System.out.println(result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }
    }}

我添加了一个 VM 参数,例如 jna.library.path=${pathtodll2},如果我使用该参数,则会出现以下错误,

Error: Could not find or load main class jna.library.path=D:\OCR\Tess4J\lib\win32-x86

我正在使用来自 Test4J 项目的最新版本, 2.0 版(2015 年 3 月 29 日)

  • 升级到 Tesseract 3.03 (r1050),与 Linux 上的 Tesseract 3.03RC 兼容
  • 重构 Tesseract 类以实现可扩展性和线程安全
  • 更新 Tesseract 3.02 的英语语言数据

我在 Windows 7 32 位机器上运行它。 Java 7。

当我尝试使用进程资源管理器时,我看不到 dll 正在加载,但我不确定,因为异常被立即抛出。

【问题讨论】:

  • 你能发布你的代码吗?
  • 确保您的共享库及其所有依赖库位于同一目录中,并且该目录位于jna.library.path
  • 什么 Tess4J 和 Tesseract 版本和操作系统?
  • 已经添加了你们询问的所有信息。绝对没有引用这些dll吗?但我不确定如何解决这个问题。
  • 我什至尝试将 dll 放在 System32 文件夹中,但仍然没有成功。但是我的错误消息没有说明任何特定的 dll,而是说“找不到指定的模块。”。想知道发生了什么。

标签: java api ocr tesseract jna


【解决方案1】:

我通过更新到Visual C++ Redistributable Packages for Visual Studio 2013解决了这个问题

Visual C++ Redistributable for VS2012 是不够的。

这个工具:http://www.dependencywalker.com/帮我找到了问题。

【讨论】:

    【解决方案2】:

    Visual C++ Redistributable Packages for Visual Studio 2013 是您需要在您的计算机上安装的软件包:)

    它肯定会工作 4....

    【讨论】:

      【解决方案3】:

      UnsatisfiedLinkError 的解决方案:

      1. 安装Visual C++ 2015 Redistributable Packages

      2. 尝试将 tess4j 文件夹从本地移动到发生异常的系统。

      【讨论】:

      猜你喜欢
      • 2011-11-24
      • 2013-12-16
      • 1970-01-01
      • 1970-01-01
      • 2016-04-06
      • 2021-07-27
      • 1970-01-01
      • 2016-07-05
      相关资源
      最近更新 更多