import java.io.*;/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 * 先配置环境变量
 * set path=jdk目录\bin
 * set classpath=.;jdk目录\lib
 */public class compiler {
  public compiler() {
  }
  public static void main(String[] args) {
    compiler compiler1 = new compiler();    Runtime runtime = Runtime.getRuntime();
    Process process = null;
    String line = null;
    InputStream is = null;
    InputStreamReader isr = null;
    BufferedReader br = null;
    try {
      process = runtime.exec("javac test.java -d c:/temp"); //关键是这行
    } catch (IOException e ) {
      System.out.println(e);
    }
    is = process.getInputStream();    isr=new InputStreamReader(is);
    br =new BufferedReader(isr);
    try{
      while ( (line = br.readLine()) != null) {
        System.out.println(line);
      }
    }catch  (IOException e ) {
      System.out.println(e);
      e.printStackTrace();
    }  }}