Runtime.getRuntime().exec()
<1 min read
Using Runtime.getRuntime().exec() to launch an application is pretty straight forward, except when you're trying to start an application whose name contains one or more spaces.
Under Windows, you need to quote the application name:
Runtime.getRuntime().exec("\"My Appliaction.exe\"");
Under Mac OS X, you need to call open:
Runtime.getRuntime().exec(new String[]{"open", "My Application.app"});
Under Linux? I'm not sure. So far I haven't figured it out.
Comments
2 (Closed)
Jim Russell
May 18, 2006
By passing an array instead of a single String, you don't go through the tokenizer:
Runtime.getRuntime().exec(new String[]{"My Application"});
Erik C. Thauvin
May 18, 2006
I just created a wiki page outlining all of the options.
Thanks.