1

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 Answers1

1

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(); // :)
Joni
  • 108,737
  • 14
  • 143
  • 193
  • Thank you. Not worked in IDE (idea), but worked like a charm if starting from terminal Final aim not using terminal thou(, could you advice smth for reading - couse for me was not clear from spec that "inheritIO" will bring it to life - at least in terminal? – Chugunov Victor Aug 10 '20 at 12:20
  • Yes IDE output "terminals" often don't have a real terminal device attached to them. – Joni Aug 10 '20 at 12:22