How to use the Tesseract API (to perform OCR) in your java code

Hi there,

I have been working on a small app recently which reads an image and converts it into text using optical character recognition. I have been doing some research on the internet for APIs to do this and found this free OCR API – tesseract.

I tried to follow the instructions therein to use it in my java code and trust me guys it took me almost 3 hours to get my code functional. So, I decided to help out ppl with a similar interest (or similar problem) and I am posting this to help you out.

I have made a video of all these steps given below. (Please read the steps once to get a basic idea).

Step 1:

You will need a JNA wrapper to use tesseract in your java project. I have used tess4j for this. It can be downloaded from here http://tess4j.sourceforge.net/

Step 2:

Now extract the contents of the tess4j archive to your desktop or any other location.

Step 3:

Open netbeans and then click on open project –> navigate to the place where you extracted the tess4j archive and then choose tess4j project. Now you should see the tess4j project in your projects tab as shown below.

proj

 

Step 4:

Now open a new Java project in your netbeans and type the below code.

 

and save the file.

Step 5:

Now expand the tess4j project (click on the + sign before it) and expand source packages; inside you will find 3 packages. Copy all of them into your project’s source packages. It should now look like as shown below.

proj2

 

Here ocr is the name of the project I created.

Step 6:

Now right click on libraries and choose add JAR\Folder as shown below:

proj3

 

Navigate to the location where you extracted the tess4j archive. Open the folder (Tess4j) and navigate to lib. There you will see 4 jar files. Choose all of them and click open. Your libraries folder should look like as shown below now.

proj4

Step 7:

Phew… Almost there. Now you will find 2 dll files in the Tess4j folder (The folder which you extracted) namely liblept168.dll and libtesseract302.dll. Copy these two files into the net.sourceforge.tess4j package and it should now look like as shown below.

proj5

 

 

Thats it…!!! Run your code and it should display the text in your image in the output console window (usually present at the bottom if you use netbeans).

You could also write the text into a file or do other manipulations with the text obtained from the image.

If you are stuck inbetween or couldn’t follow any step in this post feel free to drop a comment and I will help you out.. Peace.. :)

  • Could someone assit me with this?

    • admin

      @Cheap car Insurance quotes: Yep..!! Which step are you stuck in..?

    • zziwa

      Thanks alot.
      am using eclipse
      but am having the following errors . help me please

      Exception in thread “main” java.lang.NullPointerException
      at gnu.cajo.Cajo.main(Cajo.java:343)

  • Geetanjali

    Thanks for the detailed instructions, it worked for me!

    For folks who are still struggling – I was getting the same error, the trick was I copied both the dll’s in the /bin directory and issue got resolved.

  • Gilberto

    Guys, I followed all steps and it doesn’t work. I’m getting the exeception:
    Exception in thread “main” java.lang.UnsatisfiedLinkError: %1 não é um aplicativo Win32 válido.

    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.(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.(TessAPI.java:38)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:286)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:222)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:173)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:158)
    at javaapplication.JavaApplication.main(JavaApplication.java:19)
    Java Result: 1

    • chetan

      I keep getting this error as well, can someone please tell me how to solve this?

  • karmadip

    i found same error:
    Exception in thread “main” java.lang.UnsatisfiedLinkError: %1

    could some one please help??

  • Ashish

    Hi ,
    Can I get any jar so that it can support other language like Hindi Chines .

  • haythem

    Hey

    if u have a problem
    u have to install jdk1.8 32bit and add it in netbeans

    thnx u

  • chester

    Exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(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.testocr.TessTrial.main(TessTrial.java:19)

  • Greate pieces. Keep posting such kind of information on your page.
    Im really impressed by it.
    Hey there, You have done a great job. I’ll certainly digg it and in my opinion suggest to my friends.
    I am sure they’ll be benefited from this web site.

  • Divya

    Hi,

    I’m implementing it in Web application, but has some error
    java.lang.IllegalStateException: Input not set
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.getNumImages(JPEGImageReader.java:357)
    at com.pumex.FRACTS.DataEntry.dao.ImageIOHelper.getIIOImageList(ImageIOHelper.java:298)
    at com.pumex.FRACTS.DataEntry.dao.Tesseract.doOCR(Tesseract.java:172)
    at com.pumex.FRACTS.DataEntry.dao.Tesseract.doOCR(Tesseract.java:157)
    at com.pumex.FRACTS.DataEntry.controller.DEController.getDataEntryCrop(DEController.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

  • Divya

    Hi,
    Please help, I want to know how the dll works in Java Web application. UnsatisfiedLinkError occur

    • ajinkya

      hii i got same error..
      have you solve it…?????

  • abc

    Exception in thread “main” java.lang.Error: Invalid memory access
    at com.sun.jna.Native.invokePointer(Native Method)
    at com.sun.jna.Function.invokePointer(Function.java:470)
    at com.sun.jna.Function.invoke(Function.java:404)
    at com.sun.jna.Function.invoke(Function.java:315)
    at com.sun.jna.Library$Handler.invoke(Library.java:212)
    at com.sun.proxy.$Proxy0.TessBaseAPIGetUTF8Text(Unknown Source)
    at net.sourceforge.tess4j.Tesseract.getOCRText(Tesseract.java:336)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:232)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:173)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:158)
    at com.ocr.Main.main(Main.java:15)

  • kevin

    Apr 18, 2014 10:38:07 PM net.sourceforge.tess4j.Tesseract doOCR
    SEVERE: Input not set
    java.lang.IllegalStateException: Input not set
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.getNumImagesOnThread(JPEGImageReader.java:396)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.getNumImages(JPEGImageReader.java:384)
    at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(ImageIOHelper.java:298)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:176)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:160)
    at ocrtest.OCRTest.main(OCRTest.java:15)

    java.lang.IllegalStateException: Input not set
    BUILD SUCCESSFUL (total time: 0 seconds)

  • Jack

    Hello,
    I have tried to install it on my PC with Eclipse and I have the following error:
    Exception in thread “main” java.lang.UnsatisfiedLinkError: %1 n’est pas une application Win32 valide
    I tried a lot of different solutions but I cannot succeed. Could you help me? Thank you

    • admin

      Sure Jack.. Could you please let me know which version of eclipse you tried to install..?

  • POOJA

    I am getting this error. Can u please help me to resolve this error ???

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’: Native library (win32-x86-64/libtesseract302.dll) not found in resource path ([file:/C:/Users/POOJA/Desktop/Tess4J/lib/ghost4j-0.5.1.jar, file:/C:/Users/POOJA/Desktop/Tess4J/lib/jai_imageio.jar, file:/C:/Users/POOJA/Desktop/Tess4J/lib/jna-4.1.0.jar, file:/C:/Users/POOJA/Desktop/Tess4J/lib/junit-4.10.jar, file:/C:/Users/POOJA/Desktop/Tess4J/lib/log4j-1.2.17.jar, file:/C:/Users/POOJA/Desktop/JavaApplication3/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.(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.(TessAPI.java:38)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:278)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:214)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:165)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:150)
    at javaapplication3.JavaApplication3.main(JavaApplication3.java:27)
    Java Result: 1

    • Shubhangi Shinde

      U have add library file of tess4j.It will get on SourceForge.net

    • Shubhangi Shinde

      Also copy the libtesseract302.dll ,liblept168.dll file in your project.

  • can you reexplain it again… i don’t know hwere i messed up :(

  • dinesh

    Hi admin.
    When i running this project, i got the error
    java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’

    So i tried the same in 32 bit system.
    there i go tthis below error.

    “IIOException: JFIF APP0 must be first marker after SOI”

    Kindly advise to fix the issue.

  • varma

    is it work fr other o/s except windows?

  • sunil

    how to run it on eclipse can any one tell me the steps???

    Kindly wxplain me from creating new project step
    sunil

    sunil.s581@wipro.com

  • Narayan Choudhary

    very nice tutorial ………thank you so much,,,,,,,….please give me code for a crop and retrieve text from a particular rectangle…
    please reply me fast…….

    thanxxx…

  • Sunil

    HI Admin,

    Thank you very much Dude you did a splendid work.

    I want use my own trained tessdata file inside the code. Can you pls tell me that how to use tessdata folder iside the code?

    • admin

      Sir, I don’t understand what you meant by trained tessdata file. Could you please elaborate? (You could drop me a mail and I would be glad to help you)

  • admin

    Hi Everyone,
    I am really sorry for taking so much time to respond to your queries. I could see that a lot of ppl are trying this up with eclipse. I will soon post the same. Thank you.

  • Reshu

    Hi,

    I tried your steps but I got error which was showing that it needed some libtesseract.so file which was not in my system and my system is 64 bit. When I googled it this is showing system’s bit size problem. How can I get this libtesseract.so file and how can I use this?

  • prathi

    hi,
    i am getting this exception. pls help me. thanku.

    net.sourceforge.tess4j.Tesseract doOCR
    SEVERE: No input source set!
    java.lang.IllegalStateException: No input source set!
    at com.sun.imageio.plugins.png.PNGImageReader.getNumImages(PNGImageReader.java:1318)
    at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(ImageIOHelper.java:297)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:165)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:150)
    at ocr.Main.main(Main.java:21)

    its an exception

  • prathi

    it works.. the oly thing is…. it accepts oly thesee image formats..
    .ppm, .pbm, .pgm, .jp2

  • Kaspar Riesen

    Thank you for this nice tutorial. I tried to follow the steps on my 64Bit Mac and Eclipse. Yet, I get the following error message when I try to run the sample program:

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘tesseract’: Native library (darwin/libtesseract.dylib) not found in resource
    path

    Any idea how to fix this?

    Rgds

  • shantanu

    I am getting following error Can anybody help?
    SEVERE: Error looking up function ‘gsapi_new_instance’: The specified procedure could not be found.

  • wirher

    OMG! You saved me sooooo much time! Thank you for this entry, thank you!

    • Bimla Madhavee

      Can you please help me with the above program? Although I worked according to the above steps I get a runtime error which is
      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.NativeLibrary.loadLibrary(NativeLibrary.java:263)
      at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
      at com.sun.jna.Library$Handler.(Library.java:147)
      at com.sun.jna.Native.loadLibrary(Native.java:502)
      at com.sun.jna.Native.loadLibrary(Native.java:481)
      at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source)
      at net.sourceforge.tess4j.TessAPI.(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 tesseractexample.TesseractExample.main(TesseractExample.java:22)
      Java Result: 1
      I don’t know how to correct it. Thank you in advance

  • Matheus

    Hello, i tried using your tutorial with NetBeans and got stuck with “Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’ ” it seems that this problem is caused by the usage of 32 bits dll in a 64bits jvm. However i can’t pass this. I also tried using the 64 bits of the dlls but nothing worked

  • sourav

    Getting the following error on following the above steps –

    Error opening data file ./tessdata/eng.traineddata
    Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your “tessdata” directory.
    Failed loading language ‘eng’
    Tesseract couldn’t load any languages!

  • illuminati

    i get this error..

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’: Native library (win32-x86-64/libtesseract302.dll) not found in resource path ([file:/C:/Users/VARUN/Documents/NetBeansProjects/Tess4J/lib/ghost4j-0.5.1.jar, file:/C:/Users/VARUN/Documents/NetBeansProjects/Tess4J/lib/jai_imageio.jar, file:/C:/Users/VARUN/Documents/NetBeansProjects/Tess4J/lib/jna-4.1.0.jar, file:/C:/Users/VARUN/Documents/NetBeansProjects/Tess4J/lib/junit-4.10.jar, file:/C:/Users/VARUN/Documents/NetBeansProjects/Tess4J/lib/log4j-1.2.17.jar, file:/C:/Users/VARUN/Documents/NetBeansProjects/ocr_reader/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.(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.(TessAPI.java:38)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:278)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:214)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:165)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:150)
    at ocr.Main.main(Main.java:13)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

  • Jaunty

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’: Native library (win32-x86/libtesseract302.dll) not found in resource path ([file:/C:/Tess4J/lib/commons-io-2.4.jar, file:/C:/Tess4J/lib/ghost4j-0.5.1.jar, file:/C:/Tess4J/lib/jai_imageio.jar, file:/C:/Tess4J/lib/jna-4.1.0.jar, file:/C:/Tess4J/lib/junit-4.10.jar, file:/C:/Tess4J/lib/log4j-1.2.17.jar, file:/C:/Tess4J/build/classes/, file:/C:/Users/admin/Documents/NetBeansProjects/TesseractExample/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.(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(LoadLibs.java:78)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:33)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:303)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:239)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:188)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:172)
    at tesseractexample.TesseractExample.main(TesseractExample.java:23)

  • Yaz

    Error :SEVERE: Couldn’t seek!
    javax.imageio.IIOException: Couldn’t seek!
    at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.locateImage(TIFFImageReader.java:256)
    at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.getNumImages(TIFFImageReader.java:279)
    at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(ImageIOHelper.java:331)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:188)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:172)
    at Test.main(Test.java:11)
    Caused by: java.io.EOFException
    at javax.imageio.stream.ImageInputStreamImpl.readShort(Unknown Source)
    at javax.imageio.stream.ImageInputStreamImpl.readUnsignedShort(Unknown Source)
    at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.locateImage(TIFFImageReader.java:243)

    I am using Eclipse Kepler
    Please tell me a solution

  • huypc

    thanks admin,

    hope to create a community of research and pattern recognition or OCR

    thank you very much!!!

  • RJ

    Exception in thread “main” java.lang.ExceptionInInitializerError
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:303)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:239)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:188)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:172)
    at ocr.Main.main(Main.java:14)
    Caused by: java.lang.RuntimeException: Uncompilable source code – package net.sourceforge.tess4j.util does not exist
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:22)
    … 5 more
    Java Result: 1

  • hemraj kumawat

    When doing OCR for multiple language in the same file where to put tessdata input for multiple languages ?

  • Parth Anjaria

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’: Native library (win32-x86-64/libtesseract302.dll) not found in resource path ([file:/F:/ocr/Tess4J/lib/ghost4j-0.5.1.jar, file:/F:/ocr/Tess4J/lib/jai_imageio.jar, file:/F:/ocr/Tess4J/lib/jna-4.1.0.jar, file:/F:/ocr/Tess4J/lib/junit-4.10.jar, file:/F:/ocr/Tess4J/lib/commons-io-2.4.jar, file:/F:/null/ocr/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.(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(LoadLibs.java:78)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:33)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:303)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:239)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:188)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:172)
    at ocr.Main.main(Main.java:24)

    i am getting this error..
    cant find any solution to it. please help me admin.
    i need to give the project asap

  • Parth Anjaria

    getting the following error, please reply asap, i need it in my project:

    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.(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.(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 tess4j.TesseractExample.main(TesseractExample.java:27)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 8 seconds)

    • Parth Anjaria

      dude can u help me im getting the same error

  • Atdhe Muhaxhiri

    I’v tried in mac OS X but w/o lack. After going through your step I have this error:
    run:
    Mar 20, 2015 7:11:05 PM net.sourceforge.tess4j.Tesseract doOCR
    SEVERE: Input not set
    java.lang.IllegalStateException: Input not set
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.getNumImagesOnThread(JPEGImageReader.java:401)
    at com.sun.imageio.plugins.jpeg.JPEGImageReader.getNumImages(JPEGImageReader.java:389)
    at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(ImageIOHelper.java:331)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:188)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:172)
    at testtess4j.TestTess4J.main(TestTess4J.java:25)

    java.lang.IllegalStateException: Input not set
    BUILD SUCCESSFUL (total time: 2 seconds)

  • Overseas

    I have done setup on my linux machine can you please help me out alternatives for dll cause im getting error as
    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘tesseract’:

  • jose

    Hola, estoy intentando seguir sus pasos pero tengo problemas (Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract303’: Native library (win32-x86-64/libtesseract303.dll) not found in resource path). Trabajo con Netbeans. ¿podría enviarme el proyecto ejemplo?

    Gracias.

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

    for those who get the above exception,

    Try downloading and installing Visual C++ Redistributable Packages for Visual Studio 2013

    http://www.microsoft.com/en-au/download/details.aspx?id=40784

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

    for above expection install “Visual C++ Redistributable Packages for Visual Studio 2013”

    http://www.microsoft.com/de-ch/download/details.aspx?id=40784

    • Horst

      Thanks, this solved for me !

  • Shivank Goel

    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:78)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:40)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:360)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:273)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:205)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:189)
    at tess4j.example.TesseractExample.main(TesseractExample.java:22)
    Java Result: 1

  • Shivank Goel

    run:
    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract303’: Native library (win32-x86-64/libtesseract303.dll) not found in resource path ([file:/C:/Users/shivank/Desktop/Tess4J/lib/jai_imageio.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/jna.jar, file:/C:/Users/shivank/Desktop/Tess4J/build/classes/, file:/C:/Users/shivank/Desktop/Tess4J/lib/commons-beanutils-1.9.1.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/commons-io-2.4.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/commons-logging-1.1.3.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/ghost4j-0.5.1.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/itext-2.1.7.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/junit-4.10.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/log4j-1.2.17.jar, file:/C:/Users/shivank/Desktop/Tess4J/lib/xmlgraphics-commons-1.5.jar, file:/C:/Users/shivank/Documents/NetBeansProjects/TesseractExample/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.(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(LoadLibs.java:78)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:40)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:360)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:273)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:205)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:189)
    at tess4j.example.TesseractExample.main(TesseractExample.java:22)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

  • Bahar

    Admin,
    I am running NetBeans in Linux, But in Step 7 I don’t have , and if I run my code I get this error :
    “Unsupported image format. May need to install JAI Image I/O package.”

    SEVERE: Unsupported image format. May need to install JAI Image I/O package.
    https://java.net/projects/jai-imageio/
    java.lang.RuntimeException: Unsupported image format. May need to install JAI Image I/O package.
    https://java.net/projects/jai-imageio/
    at net.sourceforge.tess4j.util.ImageIOHelper.getIIOImageList(ImageIOHelper.java:330)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:205)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:189)
    at tesstest.TessTest.main(TessTest.java:20)

    java.lang.RuntimeException: Unsupported image format. May need to install JAI Image I/O package.
    https://java.net/projects/jai-imageio/

    Would be great if you help me.

  • ajinkya badwe

    hii everyone… i am solving ” unsatisfied link error ” and “libtesseract302.dll not found error” sucessfully

    I mention following steps so please follow that steps to implement tess4j in eclipse …

    1) first remove the spaces between workspacese..
    ie:- workspace should not be =”c:/ Document and setting/.. blal..lal.
    workspace should be =”c:/DocumentandSetting/…..etc.

    2) create new project and add
    a) tess4j .jar
    b) common io.jar,
    c) jai_imageio.jar
    and jna.jar file add thease 4 jar in build path …

    follow these steps to add jar in eclipse build path .
    1) right click on project ,
    2) go to properties .
    3) go in java build path
    4) click on libraries tab
    5) click on add external jar button and add these 4 JAR.

    3) create demo class and add following code in that class
    i.e:-

    public static void main(String[] args) {
    File imageFile = new File(“D:/workspace/Tess4jDemo/eurotext.tif”);
    Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping
    instance.setDatapath(“data”);
    instance.setLanguage(“eng”);
    // Tesseract1 instance = new Tesseract1(); // JNA Direct Mapping
    // File tessDataFolder = LoadLibs.extractTessResources(“tessdata”); // Maven build bundles English data
    // instance.setDatapath(tessDataFolder.getAbsolutePath());

    try {
    String result = instance.doOCR(imageFile);
    System.out.println(result);
    } catch (TesseractException e) {
    System.err.println(e.getMessage());
    }

    }

    4) create data and lib folder in project.

    5) in that data folder add tessdata folder . that download from hear
    unzip the folder and copy tessdata folder and paste it in data folder.
    6)then create lib folder add 32 bit dll in that folder. ie
    a)gsdll32.dll
    b)liblept168.dll
    c)libtesseract302.dll

    7) and run the program . u will get output sucessfully.

    thank you.

    • pralhad yesare

      i want your help…

      • Ajinkya Badwe

        yes

    • kumar

      hi ajinkya
      I have tried same but getting below error,please helpASAP

      Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/bridge/SLF4JBridgeHandler
      at net.sourceforge.tess4j.util.LoggerConfig.loadConfig(Unknown Source)
      at net.sourceforge.tess4j.util.LoggHelper.toString(Unknown Source)
      at net.sourceforge.tess4j.Tesseract.(Unknown Source)
      at Demo.main(Demo.java:11)
      Caused by: java.lang.ClassNotFoundException: org.slf4j.bridge.SLF4JBridgeHandler
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      … 4 more

  • Nishant

    @admin,
    Thanks for the detailed steps
    Were you able to write down the steps for eclipse as well?
    If yes please share the url for the same
    Thanks,
    Nishant

  • Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract303’: Native library (win32-x86-64/libtesseract303.dll) not found in resource path ([file:/C:/Users/OWNER/Downloads/Bilal/Tess4J/lib/ghost4j-0.5.1.jar, file:/C:/Users/OWNER/Downloads/Bilal/Tess4J/lib/jna.jar, file:/C:/Users/OWNER/Downloads/Bilal/Tess4J/lib/junit-4.10.jar, file:/C:/javacv-bin/javacv.jar, file:/C:/Users/OWNER/Downloads/Bilal/Tess4J/lib/commons-beanutils-1.9.1.jar, file:/C:/Users/OWNER/Downloads/Bilal/Tess4J/lib/commons-io-2.4.jar, file:/C:/Users/OWNER/Downloads/Bilal/Tess4J/lib/jai_imageio.jar, file:/C:/Users/OWNER/Documents/NetBeansProjects/OCR/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Native.register(Native.java:1396)
    at com.sun.jna.Native.register(Native.java:1156)
    at net.sourceforge.tess4j.TessAPI1.(TessAPI1.java:39)
    at ocr.OCR.main(OCR.java:23)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)

  • Prasad Madge

    I am getting the following error
    Exception in thread “main” java.lang.Error: Unresolved compilation problems:
    The constructor File() is undefined
    Syntax error on tokens, delete these tokens

    at Main.main(Main.java:8)

    this is the Main class

    import java.io.*;
    import java.io.File;
    import net.sourceforge.tess4j.*;

    public class Main {
    public static void main(String[] args) {

    File imageFile = new File(“C:/Users/pm831457/Desktop/Screenshot/a1.png”);
    Tesseract instance = new Tesseract(); //

    try {

    String result = instance.doOCR(imageFile);
    System.out.println(result);

    } catch (TesseractException e) {
    System.err.println(e.getMessage());
    }
    }
    }

  • prateek varpe

    for ‘Exception in thread “main” java.lang.UnsatisfiedLinkError: ‘
    1 ) Go to ‘http://tess4j.sourceforge.net/usage.html’ click on -“Visual C++ Redistributable for VS2012 ” donwload it and run (VSU_4\vcredist_x64.exe or VSU_4\vcredist_x84.exe depending upon your system configuration )
    2 put your dll files inside lib folder along with your libraries (ex \lib\win32-x86\your dll files)
    3 tessdata folder is imp one so kept it along with src ,lib folders
    now it will work .
    Thank you

  • pooja

    i have downloaded tesseract 3.02 …which other files do i have to download ? i am doing a project based on OCR

    • Shiva Krishna Yadav

      did u complete ur ocr project? Please let me know some more about ur project.

  • jaswant

    @Muhammad Junaid Khan please check you dll path.

    And also you need to get two more dlls
    msvcr120.dll
    msvcp120.dll

  • Pravindu Luke

    Solved “Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302′: Native library (win32-x86/libtesseract302.dll)” in Eclipse.
    Copy the folder win32-x86 folder or win32-x86-64 folder which is inside the lib and paste on src of your project

  • Farida El Kerdany

    Hi, thanks a lot for your effort….but i’m still waiting for the eclipse version :)

    • admin

      Hello,

      Thanks. I am working on a ANN based character recog system in javascript. Will let you know once done.

      • meir

        Hi,

        Do you know why I am getting this warning?

        java.lang.UnsatisfiedLinkError: The specified module could not be found.

        at com.sun.jna.Native.open(Native Method)

        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:263)

        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)

        at com.sun.jna.Library$Handler.(Library.java:147)

        at com.sun.jna.Native.loadLibrary(Native.java:502)

        at com.sun.jna.Native.loadLibrary(Native.java:481)

        at Tess4j.Tessaracttest.(Tessaracttest.java:33)

        Exception in thread “main” Java Result: 1

  • Kumar

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract304’: Native library (win32-x86-64/libtesseract304.dll) not found in resource path ([file:/D:/NetbeansProjectsPunitha/failed/lib/commons-beanutils-1.9.2.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/commons-io-2.4.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/commons-logging-1.2.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/ghost4j-1.0.0.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/hamcrest-core-1.3.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/itext-2.1.7.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/jai_imageio.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/jna.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/jul-to-slf4j-1.7.13.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/junit-4.12.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/lept4j-1.0.1.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/log4j-1.2.17.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/logback-classic-1.1.3.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/logback-core-1.1.3.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/rococoa-core-0.5.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/slf4j-api-1.7.13.jar, file:/D:/NetbeansProjectsPunitha/failed/lib/xmlgraphics-commons-1.5.jar, file:/D:/NetbeansProjectsPunitha/failed/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
    at com.sun.jna.Library$Handler.(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:502)
    at com.sun.jna.Native.loadLibrary(Native.java:481)
    at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:77)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:42)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
    at failed.Failed.main(Failed.java:32)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 5 seconds)

    how to solve this

    please help me…….

  • Daniyar

    Hi! can someone help me!? I tried to use it on netbeans then I have errors like that:

    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract304’: Native library (win32-x86-64/libtesseract304.dll) not found in resource path ([file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/commons-beanutils-1.9.2.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/commons-io-2.4.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/commons-logging-1.2.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/ghost4j-1.0.0.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/hamcrest-core-1.3.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/itext-2.1.7.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/jai_imageio.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/jna.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/jul-to-slf4j-1.7.13.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/junit-4.12.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/lept4j-1.0.1.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/log4j-1.2.17.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/logback-classic-1.1.3.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/logback-core-1.1.3.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/rococoa-core-0.5.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/slf4j-api-1.7.13.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/lib/xmlgraphics-commons-1.5.jar, file:/C:/Users/Daniyar/Desktop/Tess4J-3.0-src/Tess4J/build/classes/, file:/C:/Users/Daniyar/Documents/NetBeansProjects/JavaApplication7/build/classes/])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:277)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)
    at com.sun.jna.Library$Handler.(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:502)
    at com.sun.jna.Native.loadLibrary(Native.java:481)
    at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:77)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:42)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
    at javaapplication7.Main.main(Main.java:20)
    Java Result: 1

  • billel

    I tried but I get this error message :

    java.lang.IllegalStateException: Input not set

  • Moukthika Vasa

    I am getting this warning whenever i run the project.Can you please help me out to solve it asap.it’s very urgent..

    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.NativeLibrary.loadLibrary(NativeLibrary.java:263)

    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)

    at com.sun.jna.Library$Handler.(Library.java:147)

    at com.sun.jna.Native.loadLibrary(Native.java:502)

    at com.sun.jna.Native.loadLibrary(Native.java:481)

    at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source)

    at net.sourceforge.tess4j.TessAPI.(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 tess4j.example.Tessaracttest.main(Tessaracttest.java:27)

    Java Result: 1

    BUILD SUCCESSFUL (total time: 0 seconds)

    • Ajinkya Badwe

      please insert tess4j path in project.. see my last comment below.

  • radhikadevi muthyala

    I am getting this warning whenever i run the project.Can you please help me out to solve it asap.it’s very urgent.

    java.lang.UnsatisfiedLinkError: The specified module could not be found.

    at com.sun.jna.Native.open(Native Method)

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:263)

    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)

    at com.sun.jna.Library$Handler.(Library.java:147)

    at com.sun.jna.Native.loadLibrary(Native.java:502)

    at com.sun.jna.Native.loadLibrary(Native.java:481)

    at Tess4j.Tessaracttest.(Tessaracttest.java:33)

    Exception in thread “main” Java Result: 1

    • admin

      The unsatisfied link error usually occurs when there is a mismatch in the jdk/jre installed and the tesseract libs you use. Please google and download the 64-bit libraries and try the same method again.

  • Safaa Al-Husban

    I am getting this warning whenever i run the project.Can you please help me out to solve it
    Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘libtesseract302’: The specified module could not be found.

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:194)

    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:283)

    at com.sun.jna.Library$Handler.(Library.java:142)

    at com.sun.jna.Native.loadLibrary(Native.java:368)

    at com.sun.jna.Native.loadLibrary(Native.java:353)

    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:38)

    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:254)

    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:222)

    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:168)

    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:153)

    at yarb.Main.main(Main.java:12)

    C:UsersIbrahimAppDataLocalNetBeansCache8.1executor-snippetsrun.xml:53: Java returned: 1

    BUILD FAILED (total time: 1 second)

  • meir

    Hi,
    Why I am getting this warning?

    java.lang.UnsatisfiedLinkError: The specified module could not be found.

    at com.sun.jna.Native.open(Native Method)

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:263)

    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403)

    at com.sun.jna.Library$Handler.(Library.java:147)

    at com.sun.jna.Native.loadLibrary(Native.java:502)

    at com.sun.jna.Native.loadLibrary(Native.java:481)

    at Tess4j.Tessaracttest.(Tessaracttest.java:33)

    Exception in thread “main” Java Result: 1

  • Namrata Simha

    Does Tessaract work only with English in the images?

    • maliciousmale

      No you can use diffrent language. You can see trained data for tesseract for diffrent languages from

      https://github.com/tesseract-ocr/tessdata. You need to download the data of preferred language then you can initialise your tesseract api variable like

      TessBaseAPI api = new TessBaseAPI();

      boolean init = api.init(“src/main/resources/data”, “eng”);

      For japanese charset nhocr is better.

      • Namrata Simha

        Thank you!!

      • Bilal Hussain Khan

        TessBaseAPI api = new TessBaseAPI();

        boolean init = api.init(“src/main/resources/data”, “eng”);

        can you please tell me where these line should be written in my code any specific class or some thing?

  • WarL0rd

    I did exactly as described, but there are many errors while compiling. See the image attached. Most of the errors are due to unavailability of dependencies from lept4l (atleast that’s what I think). Please help me, my work is stuck. I uploaded multiple screenshots to imgur, here’s the link. http://imgur.com/a/aiOAR

  • Nikhil Khandelwal

    Barcode recognition is possible in Tess4j?? If possible then how to do it please suggest

  • Anant Mahale

    the .jar file of project not working.

  • Anil Kumar

    this is not working on windows 10 64bit
    please help me

  • Jayant Kumar

    hii, i did same steps as explained above, but while running this project , i’m getting this error ,

    ception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library ‘tesseract’: Native library (linux-x86-64/libtesseract.so) not found in resource path ([file:/home/baryons/ANIRBAN_BACKUP/ANIRBAN_BC/Desktop/OCRtoText1/tessracttest/bin/, file:/home/baryons/ANIRBAN_BACKUP/ANIRBAN_BC/Desktop/jar%20for%20tess/tess4j-1.3.0.jar])

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)

    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)

    at com.sun.jna.Library$Handler.(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.(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 tessracttest.Main.main(Main.java:15)

    can you explain, how to resolve this error?

  • arun

    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.(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(LoadLibs.java:77)
    at net.sourceforge.tess4j.TessAPI.(TessAPI.java:42)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
    at homw.main(homw.java:22)
    Java Result: 1