简体   繁体   中英

Tess4J NoClassDefFoundError

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?

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'

将jai_imageio jar添加到您的类路径中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM