英文:
Is it possible to execute terminal-graphical-apps thru java-ProcessBuilder
问题
这是可能从Java应用程序中使用ProcessBuilder或其他方式运行类似Far/MidnightCommander(或其他带有ncurses/图形界面的终端应用程序)的子进程吗?
使用ProcessBuilder的标准示例对于像ping这样的简单命令可以正常工作:
new ProcessBuilder().command("ping -n 4 google.com").start(); // :)
但是对于far却一点用都没有:
new ProcessBuilder().command("far").start(); // :(
英文:
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
得分: 1
是的。
这些应用程序需要访问终端设备才能运行。如果您是从终端启动了Java程序,您可以让新进程继承它:
new ProcessBuilder().inheritIO().command("top").start(); // :)
否则,您需要启动一个新的终端模拟器来运行该程序:
new ProcessBuilder().command("xterm", "top").start(); // :)
英文:
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(); // :)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论