User Tools

Site Tools


tips:java:launchappwithspace

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tips:java:launchappwithspace [2009/06/08 05:03] (current)
erik created
Line 1: Line 1:
 +====== Launching an Application with a Space in its Name ======
  
 +
 +Using [[http://​java.sun.com/​j2se/​1.4.2/​docs/​api/​java/​lang/​Runtime.html#​exec(java.lang.String)|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:
 +
 +<code java>
 +Runtime.getRuntime().exec("​\"​My Appliaction.exe\""​);​
 +</​code>​
 +
 +or use a String array:
 +
 +<code java>
 +Runtime.getRuntime().exec(new String[]{"​My Application.exe"​});​
 +</​code>​
 +
 +Under Mac OS X, you need to call open:
 +
 +<code java>
 +Runtime.getRuntime().exec(new String[]{"​open",​ "My Application.app"​});​
 +</​code>​
 +
 +Under Linux, you must use a String array:
 +
 +<code java>
 +Runtime.getRuntime().exec(new String[]{"​My Application"​});​
 +</​code>​
tips/java/launchappwithspace.txt · Last modified: 2009/06/08 05:03 by erik