File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Starting an exec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Starting an exec" Watch "Starting an exec" New topic

Starting an exec

Tom Hill
Ranch Hand

Joined: Aug 24, 2003
Posts: 115
Is it possible to start a Command Prompt using Runtime.exec()

I know its possible to start applications running and i know you can use cmd /c to start a command terminal inside of java.

I would quite like to actually start a terminal up, so that if a user was watching the machine a terminal would appear for them. Any ideas?

Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

What kind of event would trigger the terminal popup? There has to be some kind of input so the system knows when to do this...

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Dustinn Yourstone

Joined: Sep 16, 2005
Posts: 4
Well, I think you can. Of cource you can just start up "cmd" and then you can set a printwriter output stream to that window and type out what you want. I have seen that done before, but I never done it myself. You could always cheat and use the Robot class though .
Tom Hill
Ranch Hand

Joined: Aug 24, 2003
Posts: 115
Ive discovered that cmd /c start /D<dir> <command> is a way of doing it. It may be necessary if you wish to close the existing terminal and start a new one.

I agree. Here's the link:
subject: Starting an exec
It's not a secret anymore!