• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run dos commands in java program?  RSS feed

 
bharathi shankar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can anyone tell me the code to execute dos commands in java?
Thanks,
Bharathi
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on what exactly you're trying to do, you'll likely want to use some form of the example at javaalmanac.com on executing a command.
http://www.javaalmanac.com/egs/java.lang/Exec.html
Note the related examples on reading output from a command and sending input to a command that you may find useful as well.
Now, if you're after a strictly windows-based solution, and you want a command prompt to appear, which does something, then the command you execute with the exec() method may need to take the form of start cmd /k myCommand.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!