从java执行外部命令/应用程序
我正在寻找一个包来支持从 Java 可靠地执行外部进程。我的标准:
- 抽象优于操作系统。因此,如果我想运行“foo”,它将在 Windows 下查找“foo.bat”、“foo.exe”,在其他操作系统下查找“foo”(或者,有一种传递 os-> 命令映射的方法) )
- 能够通过简单地给出类名和参数来执行Java类(因此包找到java命令,复制jvm标志,然后执行)
- 正确处理stdout和stderr
- 看门狗/监控功能
我已经看过commons-exec,但它看起来它只回答 3 & 4. Ant 支持执行,但仅将其用于此目的似乎有些过分了。
I'm looking for a package to support reliably executing external processes from Java. My criteria:
- Abstract over OS. So if I want to run 'foo', it will look for 'foo.bat', 'foo.exe' under windows and 'foo' under other OSs (or, have a way of passing a map of os->command)
- Being able to execute Java classes by simply giving the class name and arguments (so the package locates the java command, copies jvm flags and then executes)
- Process stdout and stderr properly
- Watchdog / Monitoring capabilities
I've looked at commons-exec but it looks like it answers only 3 & 4. Ant has support for execution but looks like an overkill to use it for this purpose only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能必须选择“commons-exec”,然后卷起袖子编写一些代码。
这些都是非常具体的要求。
You will likely have to go with 'commons-exec' and then roll up your sleeves and write some code.
Those are pretty specific requirements.