从 java 执行进程并使其保持活动状态以供输入
我想用java为fortran应用程序编写一个前端,因为据我所知,fortran没有gui支持。 ( japi 似乎不能与 ifort 一起使用,请纠正我)
我想使用 netbeans 构建 gui,然后简单地将命令发送到后台的 fortran 命令行程序。关于如何从 java 远程控制命令行应用程序有什么建议吗?
干杯, 大卫
i want to code a frontend for a fortran-application with java, since fortran has no gui-support as far as i know. ( japi does not seem to work with ifort, correct me on this one )
I want to build the gui with netbeans and then simply send the commands to a fortran commandline program in the background. Any advice on how to remote control a commandline application from java?
cheers,
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你有两种可能性。
Runtime.getRuntime().exec()
我更喜欢流程构建器。它在1.4版本中引入并提供了更好的API。
请注意,当您从另一个进程运行一个进程时,性能会有所下降。如果这对你来说很重要,我建议你让你的 Fortran 程序从标准输入读取命令。然后您可以运行该程序并将命令推送到其标准输入中。使用 ProcessBuilder 非常简单。这种进程间通信的速度相当快。
You have 2 possibilities.
Runtime.getRuntime().exec()
I prefer process builder. It was introduced in version 1.4 and provides better API.
Please note that when you are running one process from another you get some performance degradation. If it is critical for you I'd recommend you to make your fortran program to read commands from standard input. Then you can run this program and push your commands into its standard input. It is very simple with ProcessBuilder. Such process-to-process communication works pretty fast.
如果您的目标是 Fortran 程序的 GUI,则可以使用 dislin 图形库完全用 Fortran 进行编码。 dislin 主要是一个绘图包,但包括创建 GUI 的例程。它可用于多种操作系统。这些例程具有许多功能,但不如成熟的窗口库那么广泛。例如,您可以在 Fortran 中编写回调例程,以响应鼠标在 dislin 窗口中按钮上的单击。
If you goal is a GUI for a Fortran program, you can code it entirely in Fortran using the dislin graphics library. dislin is primarily a plotting packages but includes routines to create GUIs. It is available for several operating systems. These routines have many capabilities, though not as extensive as a full-fledged windowing library. For example, you can code callback routines in Fortran to respond to mouse clicks on buttons in dislin windows.
我相信它的
I believe its
此外,您还可以通过命名管道进行通信。 AFAIK,没有办法从 java 创建它们(您将在 Linux 上调用 mkfifo ,或在 Windows 上使用 winapi ),但一旦创建,您可以将它们视为用于读/写操作的“普通”文件。
Also, you could communicate via named pipe. AFAIK, there is no way to create them from java (you will have either invoke mkfifo on linux, or use winapi on windows), but once created you can treat them as "normal" files for read/write operations.