Tag Archives: Tesseract couldn’t load any languages!

[Solved] TESSDATA_PREFIX environment variable is set to the parent directory of your “tessdata” directory.

This exception happen when you trying to read text of image by using tessdata API’s. It try to get defalt path of environment variable TESSDATA_PREFIX in you application root diectory/tessdata/lang.traineddata. but if this folder and file not found then throw below exception.


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:437)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:292)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:213)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:197)
    at com.fiot.ImageTextReading.crackImage(ImageTextReading.java:22)
    at com.fiot.ImageTextReading.main(ImageTextReading.java:10)
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!


Follow these steps to resolve this issue:

  1. First download tessdata from this location https://github.com/tesseract-ocr/tessdata .
  2. Rename this unzip folder to tessdata.
  3. Copy this folder and paste it to your applciation root directory.

For all steps and environment setup follow this example: Java : Read Text from and Image Example