【问题标题】:Build jar with tess4j用 tess4j 构建 jar
【发布时间】:2015-08-23 13:20:06
【问题描述】:

我在 Intellij Idea 中创建项目,从 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 狗

&duck/goose,占 E-mail 的 12.5%......

结束

启动jar时的输出

开始

没有“错误”,没有“结束”。怎么可能?

【问题讨论】:

    标签: java intellij-idea tess4j


    【解决方案1】:

    我有同样的问题。有时由于某种原因它不能正确加载类。这就是我如何能够将它修复一段时间。

    1. 构建您的工件,然后使用 intellij 远程调试您的 jar。

    2. 找出您的应用程序在哪一行中断。

    3. 然后用try{... line where application breaks..} catch(Error e){e.getMessage(); }包裹起来
    4. 您可以在调试输出的变量“e”中看到错误消息。这样你就可以确定问题了。

    这可能不是一个合适的方法。但这就是我能够在我的 jar 文件中追踪错误的方式。
    最好将其用作一种临时方法来跟踪 jar 中的错误并找出它为什么会中断然后找出正确的方法(我目前不知道..但是听说过一些名为One-Jar) 的库来构建jar,而不会在部署时出现任何错误。

    【讨论】:

      猜你喜欢
      • 2017-03-09
      • 2020-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多