need help about process........
- by adeel amin
when i start process like process= Runtime.getRuntime().exec("gnome-terminal");, it start shell execution, i want to stop shell execution and want to redirect I/O from process, can anybody tell how i can do this?
my code is:
public void start_process()
{
try
{
process= Runtime.getRuntime().exec("bash");
pw= new PrintWriter(process.getOutputStream(),true);
br=new BufferedReader(new InputStreamReader(process.getInputStream()));
err=new BufferedReader(new InputStreamReader(process.getErrorStream()));
}
catch (Exception ioe)
{
System.out.println("IO Exception-> " + ioe);
}
}
public void execution_command()
{
if(check==2)
{
try
{
boolean flag=thread.isAlive();
if(flag==true)
thread.stop();
Thread.sleep(30);
thread = new MyReader(br,tbOutput,err,check);
thread.start();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex.getMessage()+"1");
}
}
else
{
try
{
Thread.sleep(30);
thread = new MyReader(br,tbOutput,err,check);
thread.start();
check=2;
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex.getMessage()+"1");
}
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
command=tfCmd.getText().toString().trim();
pw.println(command);
execution_command();
}
when i enter some command in textfield and press execute button, nothing displayed on my output textarea, how i can stop shellexecution and can redirect Input and output?