我希望使用Java代码在Linux机器上打开终端(命令提示符)。
我知道如何在Windows中打开命令提示符。下面的代码是我在Windows中使用的:
String command= "cmd c/start cmd.exe"
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
我希望在Linux中也能做同样的事情。
感谢您的回答。我还想运行一个sh脚本。
以下代码是否有效。
String command= "usr/bin/xterm myshell.sh";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);