creating java editor
hi all
i am creatin a small application which performs some type of functionallity as any java ide does but i have a problem in one area in my application when i create a demo.java file i compile it through runtime.exec("javac "+filepath)
this creates class file now i want to run the applicaiton and want to show the output in output window. i run the class file through runtime.exec("java "+filepath) but i dont know how can i show the output in myapplication's output window.i mean how can i fetch the output generated by program .
any smallhelp will be appriciated
thanks
[607 byte] By [
nj_javaa] at [2007-11-27 8:45:20]

# 1
First of all, please don't cross post. It annoys people here to no end
Next, to answer your question:
Runtime.exec() returns a Process object. After you have started your java program, save the Process object and either create threaded InputStream listeners for the Process input and error streams, or call Process.waitFor() and then read then info from these streams when the process finishes.
# 2
// read the output from the command
String line;
BufferedReader output = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
while ( (line = output.readLine()) != null )
{
if (line.trim().length() > 0)
System.out.println( line );
}
# 3
hi
sorry for cross posting and thanks for ur reply but i have added this code in amy applicaiton but didnt find expected output this is my code plz help
try
{
tf4.setText( ta1.getText() );
p =t.exec ("java "+tf4.getText());
String line;
BufferedReader output = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
while ( (line = output.readLine()) != null )
{
System.out.println("inside while ");
if (line.trim().length() > 0)
System.out.println( line );
}
p.waitFor();
}
catch(Exception b)
{
b.printStackTrace();
JFrame f8 = new JFrame("Exception Occured"); // Frame for find dialog box
Sample6Dialog d9 ;//dialog box
d9 = new Sample6Dialog(f8 , "Exception Occured");
d9.setVisible(true);
}