2

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.

nneonneo
  • 171,345
  • 36
  • 312
  • 383
Tushar Saurabh
  • 687
  • 2
  • 13
  • 27
  • @SSpoke - The error is Unable to load library 'libtesseract302': The specified module could not be found – Tushar Saurabh Aug 13 '13 at 17:02
  • 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. https://groups.google.com/forum/#!msg/tesseract-ocr/LgHGzwqnGdk/jNzWS4sXtGEJ – SSpoke Aug 13 '13 at 19:13

2 Answers2

0

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

Community
  • 1
  • 1
Kevin Day
  • 16,067
  • 8
  • 44
  • 68
0

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

craftsmannadeem
  • 2,665
  • 26
  • 22