开发者

Execute process from java and keeping it alive for input

开发者 https://www.devze.com 2023-01-31 03:29 出处:网络
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 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


You have 2 possibilities.

  1. Runtime.getRuntime().exec()
  2. Use ProcessBuilder.

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.


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

Runtime.getRuntime().exec(command);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号