title: Mounting and untar'ing a file in Java
body: <p>I'm currently working on a web application that involves mounting a drive and extracting a tar.gz file, all in Java. Since the application runs in a linux environment, I figured I'd try using unix commands like "mount" and "tar".</p>
  
  <pre><code>Runtime runtime = Runtime.getRuntime();
  Process proc;
  
  String mountCommand = "mount -t cifs -o username=...";
  String extractCommand = "tar xzf ..."
  
  proc = runtime.exec(mountCommand);
  proc.waitFor();
  
  proc = runtime.exec(extractCommand);
  proc.waitFor();
  </code></pre>
  
  <p>Running the mount command and extract command in the terminal works fine, but fails when FIRST run in java. The second proc.waitFor() returns exit code 2. However, running this code after the first failed attempt works fine. I have a feeling that the problem is that waitFor() isn't waiting until the mount command is fully completed. Am I missing anything important in my code?</p>
  
  <p>Also, I'd rather do this all in Java, but I had a really hard time figuring out how to untar a file, so I'm taking this approach. (oh if anyone can tell me how to do this i would be very happy). Any suggestions would be muuuuuuuuuuch appreciated!</p>