The specified module could not be found. Tess4j using maven
Hi I have a problem using the tess4j library with java. I am using maven.
Exception on thread "main" java.lang.UnsatisfiedLinkError: The specified module cannot be found.
I'm pretty sure the file set in the path exists because the method exists, returns true. The debugger shows the problem in this instruction:
String result = instance.doOCR(imageFile);
This is mistake:
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)
My addiction
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>1.3.0</version>
</dependency>
My code
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());
}
}
}
Thanks in advance.
+3
source to share
3 answers
It seems that you have not added libtesseract302.dll and liblept168.dll to your classpath. Using Maven allows you to load the tess4j banner, you still need to add libtesseract302.dll and liblept168.dll to your classpath.
To run Tess4J in Eclipse: see here Maven does step 1 and 2 for you, you still need to do step 3.
and also here , it might help you.
+3
source to share