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
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: 41823
    
  63
This article spells out some pitfalls to avoid when using Runtime.exec.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run simple windows commands through java program?