1 3 20 21 package edu.neu.ccs.jmk.sun; 22 23 import com.sun.tools.javac.Main; 24 import edu.neu.ccs.jmk.Operator; 25 import edu.neu.ccs.jmk.CommandFailedException; 26 import java.io.*; 27 28 public final class Javac1_3 implements Operator 29 { 30 31 private static final int COMPILE_OK = 0; 32 private static final Main compiler = new Main(); 33 34 public String getName() 35 { 36 return "Javac1_3"; 37 } 38 39 public void exec(String [] args, PrintWriter out) 40 throws CommandFailedException 41 { 42 44 String [] argsWithClasspath = new String [args.length + 2]; 45 argsWithClasspath[0] = "-classpath"; 46 argsWithClasspath[1] = System.getProperty("java.class.path"); 47 System.arraycopy(args, 0, argsWithClasspath, 2, args.length); 48 int errorCode = compiler.compile(argsWithClasspath); 49 if (errorCode != COMPILE_OK) 50 { 51 throw new CommandFailedException("Compiler returned: " + errorCode); 52 } 53 } 54 55 } | Popular Tags |