从Java程序在新的终端窗口中运行应用程序

从Java程序在新的终端窗口中运行应用程序,java,terminal,runtime,Java,Terminal,Runtime,可能重复: 是否可以打开终端窗口并从java窗口执行某些命令 我试过了 Runtime.getRuntime().exec("<command to execute>"); Runtime.getRuntime().exec(“”); 但它不起作用。终端窗口从未打开过 (在Windows、Mac等上…我需要多个操作系统的解决方案)您需要每个操作系统的解决方案: MacOs:Runtime.getRuntime.exec(“/usr/bin/open-a Terminal/pa

可能重复:

是否可以打开终端窗口并从java窗口执行某些命令

我试过了

Runtime.getRuntime().exec("<command to execute>");
Runtime.getRuntime().exec(“”);
但它不起作用。终端窗口从未打开过


(在Windows、Mac等上…我需要多个操作系统的解决方案)

您需要每个操作系统的解决方案:

  • MacOs:
    Runtime.getRuntime.exec(“/usr/bin/open-a Terminal/path/to/the/executable”)
  • Linux:
    Runtime.getRuntime.exec(“/usr/bin/xterm”)
  • 窗口(不确定):

    进程p=Runtime.getRuntime().exec(“cmd/c start cmd.exe”); p、 waitFor()

(对于MacOSX),如果
/path/to/executable
是一个接受参数的命令,该怎么办。我如何传递参数?