views:

125

answers:

2

How can a Java application spawn a new interactive application (e.g. an command line editor) from Java/Scala?

When I use Runtime.getRuntime().exec("vim test"), I would only get a Process instance, while vim would be running in the background; rather then appear to the user.

A: 

Assuming you're on linux you actually have to run the command in new terminal window

Runtime.getRuntime().exec(new String[]{"xterm", "-e", "vim test"});
Anton
Thanks, but I was hoping to run the app on the same terminal.
notnoop
That presumes your Java code has a controlling terminal and the standard bindings of descriptors 0, 1 and 2.
Randall Schulz
+3  A: 

You will have to wrap input and output writers using System.console()

You will have to manually redirect every input to the spawned process and every output to the user.

seanizer