Unable to load library 'tessdll'

Aseem Behl
  • Aseem Behl

    Aseem Behl - 2010-12-23

    I am trying to run the following sample program to try out Tess4J, but I am getting Unable to load library 'tessdll': exception.

    I have checked tessdll.dll is in my path.

    I am using 64-bit Windows7. Please help in resolving this issue.

    public class TesseractExample {
        public static void main(String[] args) {
            File imageFile = new File("C:\\personal\\sc.tiff");
            Tesseract instance = Tesseract.getInstance();  // JNA Interface Mapping
            try {
                String result = instance.doOCR(imageFile);
            } catch (TesseractException e) {
    Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tessdll': The specified module could not be found.
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
        at com.sun.jna.Native.register(Native.java:1018)
        at net.sourceforge.tess4j.TessDllAPI1.<clinit>(Unknown Source)
        at TesseractExample.main(TesseractExample.java:13)
  • Quan Nguyen

    Quan Nguyen - 2011-01-21

    That exception is very common for Java programs using native libraries. And the cause is most likely due to the library (.dll) not in the program's path.

    If you properly configure JDK and Ant, you can run the program's unit tests by executing the command "ant test" after making Tess4J the current directory.

  • Anonymous - 2012-02-25

    I have some problem to run tess.
    I installed ant and Sdk but the error "Unable to load library 'tessdll'" remain.
    I run the script inside the Tess4j dir just downloaded!

    Then I would to run Tess4j in a web app on tomcat.
    But when i submit a file to the server and perform the text recognition i have this error:
    at javax.imageio.spi.FilterIterator.next(Unknown Source)
    at javax.imageio.ImageIO$ImageWriterIterator.next(Unknown Source)
    at javax.imageio.ImageIO$ImageWriterIterator.next(Unknown Source)
    at net.sourceforge.vietocr.ImageIOHelper.getImageByteBuffer(ImageIOHelper.java:189)
    I tried tu put the in [tomcat}/lib but the same error.

    Help me!

  • Anonymous - 2012-02-25

    Probably is because I'm on a win 64bit platform?

    any idea?


  • Quan Nguyen

    Quan Nguyen - 2013-04-06

    For java.util.NoSuchElementException, try to call ImageIO.scanForPlugins() before doOCR().

  • Frithjof Schulte

    I try to run the example project under windows with eclipse, but I get the error

    Exception in thread "main" java.lang.UnsatisfiedLinkError: The specified module could not be found

    In the classpath of the project I have the tess4j.jar and the 4 jar files from the lib folder. The "libtesseract302.dll" is in a "lib" folder in the project folder together with the "liblept168.dll" and the "testdata" folder. This "lib" folder is added to the "java.library.path" of the java-vm (Java 6 Update 45 x32). The tess4j.jar is also added in the build path -> libraries with the "lib" folder with the dll defined as native library location.

    When I try to add the dll to the java.library.path via java code in the main function

    System.setProperty("java.library.path", System.getProperty("user.dir") + "\\lib");

    I get the following error.

    Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\eclipse Workspace\Tess4JDemo\lib\libtesseract302.dll: Can't find dependent libraries
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1028)
        at demo.SimpleExample.main(SimpleExample.java:10)

    I hope you can help me.


    Problem solve.
    I have move the dll and the testdata to the top of the projectstructure (working directory of the project) and not it works. I do not know why, because at the beginning I had already test this at this position of the structure and it did not work and this time work it.

    Last edit: Frithjof Schulte 2013-10-28
    • Elijah K

      Elijah K - 2013-10-30

      Hi Frithjof

      Am having the same problem on Netbeans, keeps alternating between

      java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302'


      java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI

      Am stuck on this for the last 3 days #frustrated Can you aide by telling me the procesess you took to eliminate your error?

  • Quan Nguyen

    Quan Nguyen - 2013-10-31


    Tess4J is itself a NetBeans project. You can simply execute the unit tests in the Test Packages inside the IDE. NB has some issues on Windows 8, however, if you happen to be using it; in that case, execute "ant test" from the command line.


  • Pradeep P

    Pradeep P - 2015-03-02

    Still I have same issue. Can ypu please help me out ??
    Exception in thread "main" java.lang.UnsatisfiedLinkError: The specified module could not be found.

    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.util.LoadLibs.getTessAPIInstance(Unknown Source)
    at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.init(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
    at com.test.tessaract.TesseractExample.main(TesseractExample.java:20)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks