尝试从Java运行jar时无法获取控制台实例

时间:2018-11-07 14:53:52

标签: java executable-jar

运行以下代码时,该代码将执行jar,并成功退出,但是jar无法正常工作,我得到的输出是“尝试从Java运行jar时无法获取控制台实例”

       final Runtime re = Runtime.getRuntime();

        final Process command = re.exec("java -jar C:\\dev\\azure-workbench-client\\src\\test\\resources\\azure-file-upload-1.1.1-SNAPSHOT-jar-with-dependencies.jar "+
        "C:\\dev\\azure-workbench-client\\src\\test\\resources\\settings.properties C:\\dev\\azure-workbench-client\\src\\test\\resources\\dummyfile");
        this.error = new BufferedReader(new InputStreamReader(command.getErrorStream()));
        this.op = new BufferedReader(new InputStreamReader(command.getInputStream()));
        // Wait for the application to Finish
        command.waitFor();
        this.exitVal = command.exitValue();
        if (this.exitVal != 0) {
            throw new IOException("Failed to execure jar, " + this.getExecutionLog());
        }
        System.out.println("** " + this.getExecutionLog());

你知道是什么原因造成的吗?

1 个答案:

答案 0 :(得分:0)

事实证明,我正在执行的jar试图使用控制台接收输入。

我删除了它,它起作用了。

相关问题