File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39547
    
  27
This article spells out some pitfalls to avoid when using Runtime.exec.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run simple windows commands through java program?
 
Similar Threads
problem in calling batch file in java
How to get both ErrorStream and InputStream of a Process
an idea
Killing process spawned by Runtime.exec()
help using runtime.exec