Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not find the specified module. Tess4j using maven

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.

like image 628
Juan Camilo Mejia Avatar asked Aug 11 '26 14:08

Juan Camilo Mejia


2 Answers

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.

like image 187
Mel Avatar answered Aug 13 '26 02:08

Mel


For the last version of tess4j - 3.0 - it is enough to add

<dependency>
    <groupId>net.sourceforge.tess4j</groupId>
    <artifactId>tess4j</artifactId>
    <version>3.0.0</version>
</dependency>

instead all previously maven dependencies which have been needed for tess4j.

like image 25
Yuliia Ashomok Avatar answered Aug 13 '26 02:08

Yuliia Ashomok