How to execute cmd commands via Java

前端 未结 11 2207
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 13:59

I am trying to execute command line arguments via Java. For example:

// Execute command
String command = \"cmd /c start cmd.exe\";
Process child = Runtime.ge         


        
11条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 14:39

    Try this link

    You do not use "cd" to change the directory from which to run your commands. You need the full path of the executable you want to run.

    Also, listing the contents of a directory is easier to do with the File/Directory classes

提交回复
热议问题