code: public static RunningJob runJob(JobConf job) throws IOException {
      JobClient jc = new JobClient(job);
      RunningJob rj = jc.submitJob(job);
      try {
        if (!jc.monitorAndPrintJob(job, rj)) {
          throw new IOException("Job failed!");
        }
      } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
      }
      return rj;
    }
docs: Utility that submits a job, then polls for progress until the job is
  complete.
  
  @param job the job configuration.
  @throws IOException if the job fails