tess4j: NoClassDefFoundError: net/sf/ghost4j/GhostscriptException
We are having trouble making the code below work. Could it be the PdfUtilities? We really appreciate any help. The stack trace is at the bottom. Let us know if you need more information.
Environment
Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS Release: 14.04 Codename: trusty java version “1.8.0_66” Java™ SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot™ 64-Bit Server VM (build 25.66-b17, mixed mode)
Code
package com.jantogal.test.pdf; //import org.ghost4j.Ghostscript; //import org.ghost4j.GhostscriptException; import java.io.File; import net.sourceforge.tess4j.Tesseract; import net.sourceforge.tess4j.TesseractException; import net.sourceforge.vietocr.PdfUtilities;
public class App { private static final String TEST_FILE_PATH = “~/workspace/pdfs/FT0.pdf”; public static void main(String[] args) { Test02(); } private static void Test02(){ Tesseract instance = Tesseract.getInstance(); File pdfDoc = new File(TEST_FILE_PATH); File pngImageFiles[] = PdfUtilities.convertPdf2Png(pdfDoc);
for (int i = 0; i < pngImageFiles.length; i++) {
try {
String ocrResult = instance.doOCR(pngImageFiles[i]);
System.out.println(ocrResult);
} catch (TesseractException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.console().readLine();
}
}
}
Solutions attempted:
(1) Tried including Ghostscript ghost4j 1.0.0 in the maven dependencies. The library was in the classpath correctly. Results: Stack trace shown below - Note: I was able to instantiate Ghostscript objects using the factory without any issues inside void main. (2) Followed the solution described here https://github.com/nguyenq/tess4j/issues/4 Results: same as (1)
Stack Trace:
The issue happens on the line * File pngImageFiles[] = PdfUtilities.convertPdf2Png(pdfDoc);*
We are just testing for the moment. The exception is: Exception in thread “main” java.lang.NoClassDefFoundError: net/sf/ghost4j/GhostscriptException at com.jantogal.test.pdf.App.Test02(App.java:24) at com.jantogal.test.pdf.App.main(App.java:19) Caused by: java.lang.ClassNotFoundException: net.sf.ghost4j.GhostscriptException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) … 2 more
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (1 by maintainers)
It worked on a VM. I’ll try again in the physical server. Let’s close it and I’ll follow up if I find any issues.
Thanks for all your help.
Sent from my iPhone