I'm developing java application which allow to white or paste a source-code and run it without doing compiling procedure manually.what it do is save java code from text-box to a text-file and execute cmd command java java-file after execute javac java-file.file.
it's work fine but this problem came across when java file doesn't have any output .i mean if code create a swing form ..cmd haven't any output.then my java program get stuck actually i can't close it.i have to use external program to close it like taskmanager. but when source-code has command-line output this problem never occurred .
OutputStream stdin = null;
BufferedReader br = null;
String line = null;
String command = null;
command = jTextField1.getText();
System.out.println(command);
Process p = Runtime.getRuntime().exec(command);
stdin = p.getOutputStream(); //use this to push commands
//processing stdout
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
// br.flush();
byte[] bytes = new byte[4096];
///////////////////////////////////////////
BufferedInputStream in = new BufferedInputStream(p.getInputStream());
while (in.read(bytes) != -1)
{
jTextArea1.append(br.readLine()+"\n");
}
///////////////////////////////////////////