Java运行时exec()行为 [英] Java Runtime exec() behavior

查看:697
本文介绍了Java运行时exec()行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过 Runtime 的实例通过 exec()方法以编程方式生成javadoc生成javadoc所需的命令。首先我不熟悉通过命令行创建javadocs,第二我不熟悉来自 Runtime 的exec()方法。作为一个测试,我能够通过 exec()命令执行从C#类编译的可执行文件,但是不能用C ++类编译的可执行文件,行为?此外,在指向JDK bin目录时,我无法通过 exec()命令执行javadoc.exe文件。如何通过 exec()参数生成javadoc,甚至可以这样做?谢谢。

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.

推荐答案

这当然是可以的。

有一些陷阱与Runtime.exec相关联。例如,如果你不消耗标准错误和标准输出流,那么任何执行的进程都将被阻塞。

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.

这也值得注意,不是你可以执行的一切控制台是可执行文件。像echo这样的系统命令将不起作用。

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

这篇关于Java运行时exec()行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆