Search code examples
javafortranremote-control

Execute process from java and keeping it alive for input


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


Solution

  • 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.