Java Runtime exec() behavior

时光毁灭记忆、已成空白 提交于 2020-01-06 12:46:08

问题


I am attempting to programmatically generate javadocs via an instance of Runtime through the exec() method by passing in the commands necessary to generate javadocs. First of all I am unfamiliar with creating javadocs via the command line and second I am unfamiliar with the exec() method from Runtime. As a test I was able to execute executables compiled from C# classes through the exec() command but was not able to do so with executables compiled from C++ classes, what is causing this behavior? Also, I was unable to execute the javadoc.exe file via the exec() command while pointing to the JDK bin directory. How can I generate javadocs via exec() arguments, and is it even possible to do so? Thanks.


回答1:


It should certainly be possible to do that.

There are some traps associated with Runtime.exec. For example, if you don't consume the standard error and standard out streams then any executed process will block.

It is also worth noting that not everything you can execute on a console is an executable. System commands like "echo" will not work.



来源:https://stackoverflow.com/questions/3929015/java-runtime-exec-behavior

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