Java 找不到指定的模块。使用maven的Tess4j
您好,我在使用java的tess4j库时遇到问题。我用的是maven 线程“main”java.lang.UnsatisfiedLinkError中出现异常:找不到指定的模块 我确信路径中设置的文件存在,因为exist方法返回true。调试程序将在此说明中显示问题:Java 找不到指定的模块。使用maven的Tess4j,java,image,maven,tess4j,Java,Image,Maven,Tess4j,您好,我在使用java的tess4j库时遇到问题。我用的是maven 线程“main”java.lang.UnsatisfiedLinkError中出现异常:找不到指定的模块 我确信路径中设置的文件存在,因为exist方法返回true。调试程序将在此说明中显示问题: String result = instance.doOCR(imageFile); 这就是错误: at com.sun.jna.Native.open(Native Method) at com.sun.jna.Native.o
String result = instance.doOCR(imageFile);
这就是错误:
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.Native.open(Native.java:1759)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
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>(TessAPI.java:45)
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:283)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:219)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:168)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:152)
at Index.main(Index.java:17)
}
提前感谢。看来您缺少了tess4j使用的本机库。下载dll并通过适当设置java.library.path来运行程序似乎您没有将libtesseract302.dll和liblept168.dll添加到类路径中。 使用Maven只能下载Tesser4jJAR,但仍然需要将libtesseract302.dll和liblept168.dll添加到类路径中 要使Tess4J在Eclipse中运行,请参见 Maven为您执行步骤1和2,您仍然需要执行步骤3
而且,它可能会帮助你 对于tess4j-3.0的最新版本,只需添加
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.0.0</version>
</dependency>
net.sourceforge.4j
tess4j
3.0.0
相反,所有以前的maven依赖项都是tess4j所需要的。您好,谢谢您的回答。我在项目中已经有了这些dll,但在下一个技巧中,我尝试执行第3步,但项目不包含文件tessdll。dllIt取决于您使用的是64位还是32位。应在C:\Windows\SysWOW64或C:\Windows\System32中找到tessdll.dll
import java.io.*;
import net.sourceforge.tess4j.*;
public class Index {
public static void main(String[] args) {
File imageFile = new File("C:\\Users\\Juan\\workspace\\TESSERACT\\src\\main\\java\\img.png");
Tesseract instance = Tesseract.getInstance(); //
try {
System.out.println( imageFile.exists());
String result = instance.doOCR(imageFile);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
}
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.0.0</version>
</dependency>