用于调用外部程序的Java库

发布于 2024-10-14 04:05:42 字数 445 浏览 6 评论 0原文

我正在寻找一个有助于运行外部程序的JAVA库。现在我在单独的线程中“手动”运行它们并捕获 I/O。

我有几个不同的外部工具要运行,我需要的是一个统一的方法来执行此操作。我要处理的任务包括: - 根据预定义的模板准备输入文件 - 运行命令 - 等待结果并解析输出文件 - 维护管道

整个管道可以被视为一个图,以外部工具为节点,以数据流为边。如果数据流允许的话,如果软件能够在并行线程中运行某些命令,那就太好了。

此类问题是否有现成的解决方案?

根据我得到的答案,我觉得我必须澄清:我不需要管道。数据流可以用文件来解决,反正我需要文件。此外,管道必须是线性的(1 个输出 -> 1 个输入),但我需要一个图表,

我已经有了 python 中的一种原型 - 一堆脚本。这很好,但对我来说 - 不可扩展。而且我调用的一些程序是用java编写的,所以用java编写整个程序会很方便。 最好的, 蒂姆

I am looking for a JAVA library that facilitates running external programs. Now I run them "manually" in a separate thread and capture I/O.

I have several different external tools to run and what I need is a uniform approach to do that. The tasks I have to handle includes:
- preparing input files according to predefined templates
- running the commands
- waiting for the results and parsing output files
- maintaining the pipeline

The whole pipeline can be considered as a graph with external tools as nodes and data flow as edges. It would be great if the software could run some of the commands in parallel threads, if the data flow permits.

Is there an existing solution of such problems?

Based on the answers I got I feel I have to clarify: I don't need pipes. Data flow can be solved with files, which I need anyway. Moreover, pipes have to be linear (1 output -> 1 input) but I need a graph

I already have a kind of a prototype in python - a bunch of scripts. It is good but as for me - not scalable. Moreover some of the programs I call are in java, so making the whole thing in java would be handy.
Best,
Tim

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

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

发布评论

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

评论(2

蓝梦月影 2024-10-21 04:05:42

如果您使用的是 Unix,您是否考虑过动态构建 Unix shell 命令行(使用管道、重定向、tee 等),然后使用 ProcessBuilder 生成这一命令> 或类似的,以及(例如)/bin/sh -c

这意味着您正在利用现有的工作基础设施来处理管道、缓冲、错误收集和管理资源。

If you're on Unix, have you thought about building a Unix shell command line dynamically (using pipes, redirection, tee etc.) and then spawning this one command off using ProcessBuilder or similar, and (say) /bin/sh -c ?

It means you're making use of an existing working infrastructure that handles pipes, buffering, error collection and managing resources.

走野 2024-10-21 04:05:42

我认为 ant 应该非常适合这个。它还具有相当好的java库来进行文件处理。在这之间,也许速度模板,我认为你应该能够做你想做的事。

I would think ant should be perfect for this. It also has fairly good java library to do file processing. Between that and maybe velocity templates, i would think you should be able to do what you want.

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