2

Possible Duplicate:
Open a new prompt/terminal window from Java

Is it possible to open a terminal window and execute certain command from a java window?

I tried

Runtime.getRuntime().exec("<command to execute>");

But it didn't work. No terminal window was ever opened.

(On Windows, Mac, etc...I need solutions for multiple operating systems)

Community
  • 1
  • 1
user1508893
  • 8,493
  • 14
  • 42
  • 55

1 Answers1

1

You need a solution for each OS:

  • MacOs : Runtime.getRuntime.exec("/usr/bin/open -a Terminal /path/to/the/executable");
  • Linux : Runtime.getRuntime.exec("/usr/bin/xterm");
  • Windows (not sure ) :

    Process p = Runtime.getRuntime().exec("cmd /c start cmd.exe"); p.waitFor();

zizoujab
  • 7,318
  • 8
  • 37
  • 70
  • (For the MacOSX), what if `/path/to/executable` is a command that takes arguments. How do I pass the arguments? – user1508893 Jul 29 '12 at 19:50