// this works
if ("Show".equals (obj))
{
try {
String command= "/usr/bin/xterm -e javac panel_1.java";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
这将打开一个xterm窗口,在panel_1.java上调用javac,如果panel_1.java是一个有效的文件,它将编译.然后xterm窗口关闭.好吧我想从编译中获取警告等,并将它们放在列表或textArea中.有任何想法吗???