Execute shell command in java

Process process = null;
process = RunTime.getRunTime (). Exec ("cp aa.txt bb.txt");
process.waitFor ();

I want to execute the shell command in java and find this function on the Internet, but I have tested it several times. Isn"t the process.waitFor () function blocking? But how many times have I tested it and found that sometimes the cp command didn"t work? What is the reason for this? How exactly does this function work?

Mar.22,2021

.exec ("cmd.exe / c" cp a.TXT B.TXT "") try

Menu