Java 运行时 exec() 行为

发布于 2024-09-27 12:50:56 字数 326 浏览 1 评论 0原文

我试图通过 Runtime 实例通过 exec() 方法以编程方式生成 javadoc,方法是传入生成 javadoc 所需的命令。首先,我不熟悉通过命令行创建 javadoc,其次,我不熟悉 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

也只是曾经 2024-10-04 12:50:56

确实应该可以做到这一点。

有一些与 Runtime.exec 相关的陷阱。例如,如果您不使用标准错误和标准输出流,则任何执行的进程都将阻塞。

还值得注意的是,并非您可以在控制台上执行的所有内容都是可执行文件。像“echo”这样的系统命令将不起作用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文