Hi I have a problem using tess4j library with java. I´m using maven.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can not find the specified module.
I´m sure that the file setted in the path exist because the method exist returns true. The debuger show the problem in this instruction :
String result = instance.doOCR(imageFile);
This is the error:
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 dependency
<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.
It seems that you didn't add libtesseract302.dll and liblept168.dll to the classpath. Using Maven only enables you to download the tess4j jar, you still need to add libtesseract302.dll and liblept168.dll to your classpath.
To get Tess4J to run 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.