从intellij执行java程序时出现问题Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified,但当从命令提示符执行相同的命令时,它工作正常。
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)发布于 2019-04-17 22:22:57
安装AWS CLI for windows后,我找到了一个解决方案。最初,我是从python安装它的。https://docs.aws.amazon.com/cli/latest/userguide/install-windows.html
https://stackoverflow.com/questions/55705474
复制相似问题