0

I'm trying to use Tess4J with the following:

public static String parseImageCharacters(BufferedImage image) throws Exception {
    Tesseract instance = Tesseract.getInstance();

    return instance.doOCR(image);
}

but I'm getting the exeption:

java.lang.NoClassDefFoundError: com/sun/media/imageio/plugins/tiff/TIFFImageWriteParam
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:237)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:221)
...

Which refers to the following line in the Tesseract class:

return doOCR(ImageIOHelper.getIIOImageList(bi), rect);

I'm using Gradle as my build tool with the dependency:

compile 'net.sourceforge.tess4j:tess4j:2.0.0'

(Any Maven solutions are fine!)

What am I missing? I've seen a few posts about including various .dll files, I thought Tess4J included all these?

Eduardo
  • 6,900
  • 17
  • 77
  • 121

2 Answers2

1

It seems you need to have the Java Advanced Imaging I/O Tools as a dependency as well.

Add this to your dependency list

'com.sun.media:jai_imageio:1.1'
tddmonkey
  • 20,798
  • 10
  • 58
  • 67
  • I Added that, re built, Eclipse is giving me a build error with the following: Project is missing required library: 'C:\Program Files\Eclipse\unresolved dependency - net.java.dev.jai-imageio jai-imageio-core-standalone 1.2-pre-dr-b04-2011-07-04' – Eduardo May 15 '15 at 11:05
  • I would check the github page for jai_imagio: https://github.com/stain/jai-imageio-core – tddmonkey May 15 '15 at 11:10
-1

Add the jai_imageio jar to your classpath.