This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to run simple windows commands through java program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to run simple windows commands through java program?" Watch "How to run simple windows commands through java program?" New topic
Author

How to run simple windows commands through java program?

Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
I have to create a simple shell that takes inputs such as "ls" which lists all files in the current directory and "run cmd" which runs the program cmd.exe. I don�t know how to do this.
I have to use System.in and System.out methods to accomplish this.
I copied the cmd.exe to my root and tried this code:

But nothing happent.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367



Try this.

Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42956
    
  73
This article spells out some pitfalls to avoid when using Runtime.exec.
 
Consider Paul's rocket mass heater.
 
subject: How to run simple windows commands through java program?
 
It's not a secret anymore!