问题描述
我尝试从另一个java应用程序中运行一个java应用程序的jar文件,但是我不能让它工作。我的代码在
I try to run a jar file of with a java application from within another java application, but I cannot get it to work. My code is below
// run Jar in other java application
Runtime run=Runtime.getRuntime();
run.exec("java -jar ManichemManagerRotas BatchProcess 8 2012");
我尝试运行 manichemmanagerrotas.jar
三个参数。
所有方法我可以做,但它不能工作仍然问题是无法运行jar文件的主要方法类,如果你有任何想法这个问题,plz给我重播我这是我的重要任务
all method i can do it but it cannot work still problem is cannot run jar file's main method class if you have any idea of this problem,plz give me replay me it's important task for me
我尝试运行jar文件,然后错误是:无法访问jarfile ManichemManagerRotas
i try to run jar file then error is that :Unable to access jarfile ManichemManagerRotas
推荐答案
尝试添加缺少 .jar :
Runtime run=Runtime.getRuntime();
run.exec("java -jar ManichemManagerRotas.jar BatchProcess 8 2012");
...您必须使用过程输出...像这样:
... and you have to consume the process output... Like this:
InputStream in = run.getInputStream();
InputStream err = run.getErrorStream();
这篇关于将Java程序运行到另一个程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!