| Author |
How to open command prompt from a java program
|
preddy Narra
Greenhorn
Joined: Jul 06, 2006
Posts: 12
|
|
Hi, How to open command prompt from a java program.. please give me the code.. PC
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Have a read of the JavaDocs for Runtime.exec. Also, have a search through this forum for references to Runtime.exec. You should find plenty example code.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Naseem Khan
Ranch Hand
Joined: Apr 25, 2005
Posts: 809
|
|
Well I tried but none of line 1, 2 or 3 starts a command prompt. I think from command prompt, I am running this program, so thats why it won't start a new process. Naseem
|
Asking Smart Questions FAQ - How To Put Your Code In Code Tags
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8263
|
|
|
What happens if you type those commands into a prompt? Do they open a new command prompt?
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Naseem Khan
Ranch Hand
Joined: Apr 25, 2005
Posts: 809
|
|
It does nothing. With the above code it does not open a new command prompt. [ July 11, 2006: Message edited by: Naseem Khan ]
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8263
|
|
|
Right. So the problem isn't with Java, it's with your use of the command line. First you should set out to discover what command will create a new window. A simple web search led me to this handy reference. Once you have the command, you'll still need a command interpreter to run it, so your exec line should include a call to it. Let us know what you try and if you are still stumped.
|
 |
Naseem Khan
Ranch Hand
Joined: Apr 25, 2005
Posts: 809
|
|
Hi Joe, With your reference and little r&d, it worked. Code below: Thanks [ August 06, 2006: Message edited by: Naseem Khan ]
|
 |
 |
|
|
subject: How to open command prompt from a java program
|
|
|