Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run simple windows commands through java program?  RSS feed

 
Unnar Björnsson
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Try this.

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article spells out some pitfalls to avoid when using Runtime.exec.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!