Runtime.execdoes not work. You cannot pass multiple commands like this to cmd.exe.
Runtime.execallows you to execute one process with a list of arguments. It does not provide any "shell" operations (for example, 2>&1). You must do this I / O redirection yourself using I / O streams.
main.
"Runtime.exec( String [] {" cmd.exe "," /c "," dir "," C:\\"});
, , java.io.File, .