exec command in java

时光总嘲笑我的痴心妄想 提交于 2019-12-24 07:58:47

问题


If i am using following command in java:

Process ps = Runtime.getRuntime().exec("some .exe file of VB");

How do I know that the particular .exe has done its job eg: it executed successfully.

How do i know that it has some error or just completed half task in java. How should I design my program in java to know or Is there any way to tell java from VB.

Any help is appreciated.


回答1:


I would assume that you could look at the exit status of the program: ps.exitValue() or you could read the stdout/stderr ps.getInputStream() / ps.getErrorStream() respectively.




回答2:


You get back a Process

http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/lang/Process.html

Which has such methods as:

exitValue() 
getErrorStream() 
waitFor()

Which will get you what you need



来源:https://stackoverflow.com/questions/3209755/exec-command-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!