示例#1
0
  public int compileJavaProgram(JavaProgram jp, String writeDirectory, String classpath)
      throws Exception {
    if (!jp.isTypeResolved()) {
      System.out.println(
          "Compilation will not take place since there were type resolution errors.");
      return -1;
    }

    String fileList = jp.getFilesAsString();
    String command = "javac -d " + writeDirectory + " -classpath " + classpath + " " + fileList;
    // System.out.println(command);
    System.out.print("Compiling...");

    Process p = Runtime.getRuntime().exec(command);
    // need to squirt the output into the
    InputStream is = p.getErrorStream();

    Util.read(is, "compiler"); // blocks here
    int exitValue = p.exitValue();
    return exitValue;
  }