0

I try to do an ocr application for Mirth with Java and Tesseract.I export the project in jar file and call in Mirth with Javascript that did a hello world application.I believe that I add the jar files right way.However I have a problem in Java OCR,so I get this error,

ERROR (com.mirth.connect.connectors.js.JavaScriptDispatcher:193): Error evaluating JavaScript Writer (JavaScript Writer "RTF>DCM" on channel b469e5af-a78d-41ca-86a0-a7b507799a4d). java.lang.NoClassDefFoundError: net/sourceforge/tess4j/TesseractException

Project Screenshot

package com.imagerad.ocr;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

public class JavaOCRTest {
static String Tc;
static String phone;
static String date;

public static void main(String[] args) throws IOException{

}

public String returnText(String fileName) throws IOException{


    Files.walk(Paths.get(fileName)).forEach(filePath -> {
        if (Files.isRegularFile(filePath)) {
            File imageFile = filePath.toFile();

            ITesseract instance = new Tesseract();

            try {
                String result = instance.doOCR(imageFile);

                int i=result.indexOf("Numarasn: ");
                int j=result.indexOf("Tel No:");
                int k=result.indexOf("Bilgllendirme Tarihl:");

                Tc = result.substring(i+10, i+22);
                phone = result.substring(j+8,j+23);
                date = result.substring(k+22,k+32);


            } catch (TesseractException e) {
                System.err.println(e.getMessage());
            }
        }
    });
    return Tc+""+phone+""+date;
}

public String returnTC() throws IOException{
    return Tc;
}

public String returnPhone() throws IOException{
    return phone;
}

public String returnDate() throws IOException{
    return date;
}
}

Thank you so much for your helps.

Nevzat Günay
  • 1,039
  • 11
  • 19
  • It's a class not found exception, so double check the path to the jars in question and that the jar files actually have the classes you think they should have (use `unzip -l file.jar`). – Robert Sep 03 '16 at 15:01
  • Thank you @Robert.I solved my problems.You can see all answers [this](http://stackoverflow.com/a/39201494/5459257) – Nevzat Günay Sep 08 '16 at 08:28

1 Answers1

3

You have to download the Tess4J.jar and add it to the classpath. This jar contains the missing class net/sourceforge/tess4j/TesseractException

Jens
  • 67,715
  • 15
  • 98
  • 113