eclipse Tess4j:java.lang.UnsatisfiedLinkError:无法加载库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25837246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:58:39  来源:igfitidea点击:

Tess4j : java.lang.UnsatisfiedLinkError: Unable to load library

eclipsedlltesseractunsatisfiedlinkerrortess4j

提问by HelloWorld0815

Im using tess4j.jar in my Eclipse project. When i run it on eclipsemy project is working fine, but when i try to run the exported runnable .jar fileit always fails due to "java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302'"error.

我在我的 Eclipse 项目中使用 tess4j.jar。当我在Eclipse上运行它时,我的项目工作正常,但是当我尝试运行导出的可运行 .jar 文件时,它总是由于“java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302'”错误而失败。

I tried to fix it with solutions from similar posts but nothing worked.

我试图用类似帖子中的解决方案修复它,但没有任何效果。

  1. Located the 'libtesseract302' and 'liblept168.dll' file into a "dll" folder an added it as source folder.
  2. I′m running java 32bit and confirmed that the dlls are also 32bit dlls.
  1. 将“libtesseract302”和“liblept168.dll”文件放入“dll”文件夹中,并将其添加为源文件夹。
  2. 我正在运行 java 32bit 并确认 dll 也是 32bit dll。

Error log:

错误日志:

Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302': Can't obtain InputStream for win32-x86/libtesseract302.dll
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.<init>(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:412)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.init(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at brain.Main.startOCR(Main.java:292)
    at brain.Main.getOcrResult(Main.java:251)

采纳答案by nguyenq

If the DLLs are packaged in the JAR file, they will need to be extracted. Then set jna.library.pathsystem property to the location of the DLL files (see Tutorial).

如果 DLL 打包在 JAR 文件中,则需要提取它们。然后将jna.library.path系统属性设置为 DLL 文件的位置(参见教程)。