“Cannot run program” when using Runtime.exec with spaces in program filename
问题 I am using the below code to open the "sample.html' file. String filename = "C:/sample.html"; String browser = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; Runtime rTime = Runtime.getRuntime(); Process pc = rTime.exec(browser + filename); pc.waitFor(); However, I am getting the below error. java.io.IOException: Cannot run program "C:/Program": CreateProcess error=2, The system cannot find the file specified Could someone please help me figure this. Thanks in advance. 回答1: