I searched a lot the last hours to open program.exe and interact with it like cmd. The solutions I found did not work or just worked for opening cmd and running commands like ‘dir’.
I want to open a program (lets say program.exe), entering a command, parsing the output and then entering the next command. The window of the command line does not have to be open/visible but I need to get the output and enter further commands. How can I do this with Java?
I think what you may be referring to opening another process and running a command-line program from it and passing arguments to this secondary process.
If so, what you are looking for is the ProcessBuilder.
You can create a Process and obtain an input stream to read from it, or an output stream to write back at it.
You might want to check the following examples: