title: using Runtime.exec() in Java
body: <p>What do you have to do in Java to get the Runtime.exec() to run a program that is on the path? I'm trying to run gpsbabel which I have put into the path (/usr/local/bin).</p>
  
  <pre><code>public class GpxLib {
  
      public static void main(String[] args) {
          try
          {
              Runtime r = Runtime.getRuntime();
              Process p = r.exec("gpsbabel -i garmin -f usb: -o gpx -F -");
              InputStream is = p.getInputStream();
              BufferedReader br = new BufferedReader(new InputStreamReader(is));
              while (true)
              {
                  String s = br.readLine();
                  if (s == null)
                      break;
                  System.out.println(s);
              }
              br.readLine();
          } catch (IOException e) {
              e.printStackTrace(System.err);
          }
      }
  }
  </code></pre>