wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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
Marshal

Joined: Mar 22, 2005
Posts: 41085
    
  43
This article spells out some pitfalls to avoid when using Runtime.exec.


Ping & DNS - my free Android networking tools app
 
Consider Paul's rocket mass heater.
 
subject: How to run simple windows commands through java program?
 
Similar Threads
How to get both ErrorStream and InputStream of a Process
Killing process spawned by Runtime.exec()
an idea
problem in calling batch file in java
help using runtime.exec