我很难正确导出Java应用程序。 当我从Eclipse运行它时,没有任何错误。
但是,在导出可运行的jar并将其转换为exe后,调用doOCR方法时出现以下错误:
String imgText = instance.doOCR(new File(path));
错误:
net.sourceforge.tess4j.TesseractException: java.lang.NullPointerException
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at logic.OCR.<init>(OCR.java:28)
at display.MainWindow$1$2.run(MainWindow.java:146)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at net.sourceforge.tess4j.util.ImageIOHelper.convertImageData(Unknown Source)
at net.sourceforge.tess4j.util.ImageIOHelper.getImageByteBuffer(Unknown Source)
at net.sourceforge.tess4j.Tesseract.setImage(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
... 5 more
tessdata
文件夹与可执行文件位于同一目录中。
如何导出应用程序,这样就不会再次出现此错误?