code: public static boolean runJob(JobConf job) throws IOException {
      JobClient jc = new JobClient(job);
      boolean sucess = true;
      RunningJob running = null;
      try {
        running = jc.submitJob(job);
        JobID jobId = running.getID();
        System.out.println("Job " + jobId + " is submitted");
        while (!running.isComplete()) {
          System.out.println("Job " + jobId + " is still running.");
          try {
            Thread.sleep(60000);
          } catch (InterruptedException e) {
          }
          running = jc.getJob(jobId);
        }
        sucess = running.isSuccessful();
      } finally {
        if (!sucess && (running != null)) {
          running.killJob();
        }
        jc.close();
      }
      return sucess;
    }
docs: Submit/run a map/reduce job.
  
  @param job
  @return true for success
  @throws IOException