问题描述
经过2天的谷歌搜索后,我仍无法找到Tess4j 3.0版本问题的解决方案:java.lang.UnsatisfiedLinkError:找不到指定的模块。
After 2 days of googling I am still unable to find the solution of my issue with Tess4j version 3.0: java.lang.UnsatisfiedLinkError: The specified module could not be found.
我在Windows 10 x64上编写服务器端Spring启动应用程序。我使用本教程
I在tess4j项目的源代码中生成 ant test
,这个命令在我的电脑上运行正常。我还安装了VS2012的Visual C ++ Redistributable和VS2013的Visual C ++ Redistributable。
但我错过了我的电脑中的dll,libtesseract304.dll取决于:
I write server side Spring boot app on my Windows 10 x64. I used this tutorial http://tess4j.sourceforge.net/tutorial/I make ant test
in tess4j project's source and this command works ok in my PC. I also have Visual C++ Redistributable for VS2012 and Visual C++ Redistributable for VS2013 installed. But I have missed dlls in my PC, libtesseract304.dll depends on:
这可能是问题的原因吗?但是怎么可能,Tess4J-3.0-src项目在我的电脑上运行正常?
Can it be the reason of problem? But how it is possible, that Tess4J-3.0-src project works ok in my PC?
我的完整堆栈跟踪:
java.lang.UnsatisfiedLinkError: The specified module could not be found.
at com.sun.jna.Native.open(Native Method) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:263) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.Library$Handler.<init>(Library.java:147) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.Native.loadLibrary(Native.java:502) ~[jna.jar:4.2.1 (b0)]
at com.sun.jna.Native.loadLibrary(Native.java:481) ~[jna.jar:4.2.1 (b0)]
at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.init(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
at ocr.OCRController.handleFileUpload(OCRController.java:109) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
我的代码:
ITesseract instance = new Tesseract(); // JNA Interface Mapping
instance.setDatapath(new File(datapath).getPath());
instance.setLanguage("eng");
try {
String result = instance.doOCR(imageFile); //error here
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
maven:
<dependency>
<groupId>jai_imageio</groupId>
<artifactId>com.jai_imageio</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jai_imageio.jar</systemPath>
</dependency>
<dependency>
<groupId>commons-io-2.4</groupId>
<artifactId>com.commons-io-2.4</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/commons-io-2.4.jar</systemPath>
</dependency>
<dependency>
<groupId>jna</groupId>
<artifactId>com.jna</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jna.jar</systemPath>
</dependency>
<dependency>
<groupId>tess4j-3.0</groupId>
<artifactId>com.tess4j-3.0</artifactId>
<version>3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/tess4j-3.0.jar</systemPath>
</dependency>
我还尝试以强制方式加载库:
I also tried to load libs in force way:
Runtime.getRuntime().loadLibrary("lib/win32-x86-64/gsdll64");
Runtime.getRuntime().loadLibrary("lib/win32-x86-64/libtesseract304");
但没有成功:
There was an unexpected error (type=Internal Server Error, status=500).
C:\Users\Iuliia\IdeaProjects\ENumbersBackend\lib\win32-x86-64\libtesseract304.dll: Can't find dependent libraries
感谢您的帮助!
推荐答案
该问题与Windows 10无关。
The problem is not connected with Windows 10.
我已修复错误并添加
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.0.0</version>
</dependency>
而不是所有以前的maven依赖项。
instead all previous maven dependencies.
这篇关于Windows中的Tess4j问题:java.lang.UnsatisfiedLinkError:在instance.doOCR(imageFile)中找不到指定的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!