コード例 #1
0
ファイル: Interpreter.java プロジェクト: bihai/net2java
  public int writeWebProgram(WebProgram wp, String webRoot, String classpath) throws Exception {
    String javaClassesDir = webRoot + File.separator + "WEB-INF" + File.separator + "classes";
    JavaProgram jp = wp.getJavaProgram();
    int i = this.writeAndCompileJavaProgram(jp, javaClassesDir, classpath);

    for (Iterator itr = wp.getASPs().iterator(); itr.hasNext(); ) {
      ASP asp = (ASP) itr.next();
      String aspFilename = Util.replaceString(asp.getName(), "aspx", "jsp");
      FileOutputStream fos = new FileOutputStream(new File(webRoot, aspFilename));
      asp.write(fos);
      // asp.write(System.out);
    }
    return i;
  }
コード例 #2
0
ファイル: Interpreter.java プロジェクト: bihai/net2java
  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;
  }