views:

69

answers:

1
// 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();  
  }  
}

This opens an xterm window , calls javac on panel_1.java, it compiles if panel_1.java is a valid file. then the xterm window closes. Fine I want to take the warnings, etc., from the compile and put them in a list or a textArea. Any Ideas???

+5  A: 

Java 6 has JavaCompiler from the javax.tools package which provides an API to the compiler without the need to run an external process. (read the javadoc I linked!)

Here is a little tutorial on the matter as well.

Bozho