我用Intellij创建项目,从maven添加tess4j 2.0,编写测试应用程序。当我开始调试时,一切正常。当我点击“构建工件”并启动jar文件时,我没有任何结果,没有错误,什么也没有。
public class MainApp {
static String fileName = "C:\\Users\\Alex\\Google Drive\\TW\\LIB\\Tess4J\\eurotext.png";
public static void main(String[] args) {
try {
System.setOut(new PrintStream(new File("output-file.txt")));
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Start");
ITesseract instance = new Tesseract1(); // JNA Direct Mapping
try {
String result = instance.doOCR(new File(fileName));
System.out.println(result);
} catch (TesseractException e) {
System.out.println("Error");
System.out.println(e.getMessage());
e.printStackTrace();
}
System.out.println("End");
}
}调试时输出
开始 (快)棕色的狐狸跳起来了! 超过43,456.78 #90的狗 及鸭/鹅,占电子邮件的12.5% . 结束
发射罐输出
开始
没有“错误”,没有“结束”。怎么可能?
发布于 2015-08-23 05:20:06
我也有过同样的问题。有时,由于某种原因,它无法正确加载类。这是我在很远的地方修好它的方法。
try{... line where application breaks..} catch(Error e){e.getMessage(); }包起来也许这不是一个合适的方法。但这就是我能够跟踪jar文件中的错误的方法。
无论如何,最好将此作为一种临时方法来跟踪您的jar中的错误,并找出其崩溃的原因,然后找出正确的方法(这是我目前所不知道的)。但是,听说了一些名为单缸的库可以构建jar,而不会在部署过程中出现任何错误。
https://stackoverflow.com/questions/31356638
复制相似问题