Is it possible to execute terminal-graphical-apps thru java-ProcessBuilder

201 Views Asked by At

Is it possible to run subprocesses like Far/MidnightCommander (or other terminal app with ncurses/graphical-interface) from java application with ProcessBuilder or somehow other way?

Standart examples with ProcessBuilder works fine with something simple like ping

new ProcessBuilder().command("ping -n 4 google.com").start(); // :)

, but not worked at all with far

new ProcessBuilder().command("far").start(); // :(
1

There are 1 best solutions below

2
Joni On BEST ANSWER

Yes.

These applications need access to a terminal device to work. If you started the java program from a terminal, you can use that same terminal by letting the new process inherit it:

new ProcessBuilder().inheritIO().command("top").start(); // :)

Otherwise, you need to start a new terminal emulator to run the program.

new ProcessBuilder().command("xterm", "top").start(); // :)