2
votes

All - I am trying to use tess4j in my Java project. I have followed the following steps -

  1. copied the jar files from /dist and /lib as a external jar files while creating the project.
  2. Copied the /tessdata and libtesseract302.dll to the project root and even in src folder of the project.
  3. Below is the code(tess4j example code in sf) -

    import java.io.File;
    import net.sourceforge.tess4j.*;
    
    public class ReadingImage {
    
        public static void main(String[] args) {
            File imageFile = new File("C:\\Documents and Settings\\T9SAUR\\My Documents\\Downloads\\Tess4J-1.1-src\\Tess4J\\eurotext.tif");
            Tesseract instance = Tesseract.getInstance();
            try {
                String result = instance.doOCR(imageFile);
                System.out.println(result);
            } catch (TesseractException e) {
                System.err.println(e.getMessage());
            }
        }
    }
    

yet my code is giving the error. As per the other post on the same topic, I checked the JVM version (32 bit) and eclipse version(32 bit). Please let me know, where I went wrong.

2
@SSpoke - The error is Unable to load library 'libtesseract302': The specified module could not be foundTushar Saurabh
I googled that error and found to specify exactly where the dll file is you could add -Djava.library.path=path/to/your/dll to your java run file and it should find the module. groups.google.com/forum/#!msg/tesseract-ocr/LgHGzwqnGdk/…SSpoke

2 Answers

0
votes

If you are using Eclipse to launch, then you need to specify the location of native libraries associated with the Tesseract jar. See How to set the java.library.path from Eclipse

0
votes

If you are using JNA (or your framework/library uses JNA), in this case tess4j does uses

Try this

-Djna.library.path=${workspace_loc:/ocr-tess4j-example}/dll/win32-x86-64

or

-Djna.library.path=path/to/dlls