title: Java command Runtime.getRuntime().exec() in Mac OS
body: <p>I´m using Mac OS Lion, with java version 1.6.0_26</p>
  
  <p>I'm making a small app for Mac in Java with a main menu for the user, so he can choose several options.</p>
  
  <p>One of them is install an app using a .pkg</p>
  
  <p>Everything was working fine with these commands:</p>
  
  <pre><code>File instFolder = new File(System.getProperty("user.dir") + "/foldername/appInstaller.pkg");
  String s = "open "+ instFolder.toString();
  Process p = Runtime.getRuntime().exec(s);
  </code></pre>
  
  <p>Then I realized that there is a problem when foldername has spaces or if I copy this java file with the needed subfolders to a USB pen drive with "NO NAME" as name (or some name with spaces).</p>
  
  <p>Because s will become something like:
  <br>
  <br>
  open /Volumes/NO NAME/foldername/appInstaller.pkg<br>
  or<br>
  open /Users/user1/Desktop/folder name/appInstaller.pkg<br>
  <br>
  <br><br>
  So when you run the p process, the command will finish where the first space appears on the path
  <br>
  <br>
  open /Volumes/NO<br>
  or<br>
  open /Users/user1/Desktop/folder<br>
  <br>
  <br>
  To try to fix this I changed the s definition for something like this:</p>
  
  <pre><code>String s = "open "+ "\"" + instFolder.toString() + "\"";
  </code></pre>
  
  <p>It stopped working fine.  The strange thing is that if i copy the s value (after creating the s variable) and paste it in the terminal it works:
  <br><br>
  open "/Users/user1/Desktop/folder name/appInstaller.pkg"<br>
  <br><br>
  but running it from Java it does't work.</p>
  
  <p>Could you help me, please?</p>
  
  <p>Thanks.</p>