我正在尝试从 java 类调用 bash 脚本。
这是我的java程序
import java.io.File;
public class RunBuild {
public static void main(String[] args) {
File wd = new File("/home/sai/Jan5WS/ATCore/bin/");
System.out.println("Working Directory: " + wd);
Process proc = null;
try {
proc = Runtime.getRuntime().exec(" . Ram.sh", null, wd);
System.out.println(proc.getInputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
}
我已获得该脚本的所有权限,请参见下文 sai@sai-Aspire-4720Z:~/Jan5WS/ATCore/bin$ chmod 7777 Ram.sh
-rwxrwxrwx 1 sai sai 77 Feb 3 20:53 Ram.sh~
-rwxrwxrwx 1 sai sai 79 Feb 3 20:53 Ram.sh
sai@sai-Aspire-4720Z:~/Jan5WS/ATCore/bin$
它在下面抛出这个异常
Working Directory: /home/sai/Jan5WS/ATCore/bin
java.io.IOException: Cannot run program "." (in directory
"/home/sai/Jan5WS/ATCore/bin"): error=13, Permission denied
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at RunBuild.main(RunBuild.java:12)
Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 4 more
我正在使用 Ubuntu 请让我知道可能是什么问题?