java - 尝试从 java 运行 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());
知道是什么原因造成的吗?
解决方案
原来我正在执行的 jar 试图使用控制台接收输入。
我删除了它并且它有效。
推荐阅读
- jpa - 外键的列数错误
- c# - .net 核心视图模型提供路由参数
- javascript - 以编程方式在 JSTree 中创建文件夹结构
- android - 如何解决 Quickblox 中的“基本所需会话不存在”错误?
- python - 修复opencv python + ImageMagick中detectAndCompute的windows和linux结果不一致的问题
- javascript - 如何使用 javascript 操作 json 对象并添加密钥?
- c++ - 允许通过迭代和从子集中随机选择进行更改的数据结构 (C++)
- spring - 使用 Spring 和 Reactor 的 API 组合 (BFF)
- javascript - 动态创建对象数组
- neo4j - 如何在 neo4j 中手动安装 apoc?