Can we run command prompt commands using java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we run command prompt commands using java

I want to run cmd commands like dir,cd. Can this be accomplished with java?

14th Feb 2017, 4:29 AM
Prakhar Agarwal
Prakhar Agarwal - avatar
1 Answer
+ 2
Yes, but it depends on your System as to how you do it and which commands to run. Something like: Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("dir"); Google for more answers as to what you're trying to do and on what OS.
14th Feb 2017, 5:05 AM
ChaoticDawg
ChaoticDawg - avatar