내가 process = Runtime.getRuntime().exec("gnome-terminal");
같은 프로세스를 시작, 그것은 쉘 실행을 시작합니다. 쉘 실행을 중단하고 I/O를 프로세스에서 리디렉션하고 싶다면 아무에게도이 작업을 수행 할 수 있습니까?
내 코드는 다음과 같습니다
public void start_process()
{
try
{
process= Runtime.getRuntime().exec("gnome-terminal");
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();
}
I 버튼을 실행 텍스트 필드와 언론에 몇 가지 명령을 입력하면, 아무것도 내가 쉘 실행을 중지하고 입력과 출력을 재 지정할 수 있습니다 어떻게 내 출력 텍스트 영역에 표시되지 않습니다?
중복 된 http://stackoverflow.com/questions/2992801/need-help-about-process - 동일하거나 유사한 질문을 다시 게시하지 마십시오. 대신 원본을 편집하십시오. –
당신은 이미 이것을 물어 봤습니다 –