title: Call a command in terminal using Java (OSX)
body: <p>I am trying to write Java code to run wget to retrieve an image from a server</p>
  
  <p>I believe that I have wget properly installed. If I type:</p>
  
  <pre><code>wget http://insitu.fruitfly.org/insitu_image_storage/img_dir_38/insitu38795.jpe
  </code></pre>
  
  <p>I find the image in my user account folder.</p>
  
  <p>The following Java code was working properly on Ubuntu, but I had to move the project over to OSX (Mountain Lion)</p>
  
  <pre><code>import java.io.*;
  import java.io.IOException;
  
  public class runWget
  {
  
    public static void main (String args[])
    {
      String whatToRun = "wget     http://insitu.fruitfly.org/insitu_image_storage/img_dir_38/insitu38795.jpe";
     try
     {
       Runtime rt = Runtime.getRuntime();
       Process proc = rt.exec(whatToRun);
       int exitVal = proc.waitFor();
       System.out.println("Process exitValue:" + exitVal);
     } catch (Throwable t)
       {
         t.printStackTrace();
       }
    }
  }
  </code></pre>
  
  <p>When I try to run it on OSX, I get the runtime error: </p>
  
  <blockquote>
    <p>java.io.IOException: Cannot run program "wget": error=2, No such file
    or directory</p>
  </blockquote>
  
  <p>I would greatly appreciate if someone could tell me what I am doing wrong.</p>