从intellij执行Java程序时遇到问题Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
,但是从cmd提示符执行相同命令时,它就正常工作。
public class TestRunProgram {
public static void main(String[] args) throws IOException {
String commandRun = "aws apigateway get-api-keys --profile awsProdUser --region eu-west-1";
System.out.println(commandRun);
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(commandRun);
}}
执行后出现以下问题
java.io.IOException: Cannot run program "aws": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
答案 0 :(得分:0)
在安装适用于Windows的AWS CLI后,我找到了解决方案。最初,我是从python安装的。 https://docs.aws.amazon.com/cli/latest/userguide/install-windows.html