title: Java: how to check if a program has been correctly launched?
body: <p>I am developping a little Java jar application for storage data in file.xml using BaseX server.
  AT the beginning, before the main program starts, I need that Basex Server is correctly launched and activated. So here is what I do:</p>
  
  <pre><code>Runtime runtime = Runtime.getRuntime();
  
  if (isWindows(os)) {
      Process server = runtime.exec("cmd /C basexserver.bat");
      System.out.println(server.waitFor());
  
  }
  
  else {
      if (isLinux(os)) {
          runtime.exec("basexserver");
      }
  }
  </code></pre>
  
  <p>To check if BaseXServer is correctly running I have tried to check the value returned by waitFor method and if this value is equal to 0 then the command was successfully executed while if the returned value is greater than 0 then an error has occurred. The problem is that this method always returns 1 but the command "basexserver.bat" is correct. Why? </p>