import java.io.*;
/**
*
*
*
*
* @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();
}
}
}
本文转自
http://topic.csdn.net/t/20050328/15/3888008.html
/**
*
Title:
*
Description:
*
Copyright: Copyright (c) 2005
*
Company:
* @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();
}
}
}
本文转自
http://topic.csdn.net/t/20050328/15/3888008.html