Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Starting xterm using exec and then send commands to it

843798May 19 2005 — edited May 19 2005
Hello
I don�t get this to work. I start xterm in my UNIX environment by dong the following:

try {
process = Runtime.getRuntime().exec("xterm");
} catch (IOException e) {
e.printStackTrace();
}

So long, so good. Now I want to send my xterm a command, and I try this:

BufferedOutputStream bos = new BufferedOutputStream(process.getOutputStream());
byte[] command;
try{
bos.write(command, 0, command.length);
bos.write(newline.getBytes());
bos.flush();
System.out.println("Sending command");
} catch (IOException ioe) {
ioe.printStackTrace();
}

The string "Sending command" appears but nothing else happens, not even an exception. The idea is that e.g. the command "exit" should close the xterm.

Thank you for anything.

// Adde
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2005
Added on May 19 2005
5 comments
331 views