我正在尝试使用java程序运行我的shell脚本。我得到以下异常。
java.io.IOException: Cannot run program "/home/builder/code/target/classes/idFetcher.sh": java.io.IOException: error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:605)
at java.lang.Runtime.exec(Runtime.java:443)
at java.lang.Runtime.exec(Runtime.java:340)
at script.InformationFetcher.main(InformationFetcher.java:26)
文件路径正确,文件存在于该位置。这是我的代码
package script;
import java.io.IOException;
public class InformationFetcher {
public InformationFetcher() {
}
public static void main(String[] args) {
try {
InformationFetcher informationFetcher = new InformationFetcher();
Runtime.getRuntime().exec(informationFetcher.getFilePath());
} catch (IOException e) {
e.printStackTrace();
}
}
public String getFilePath() {
return this.getClass().getResource("/idFetcher.sh").getPath();
}
}
答案 0 :(得分:1)
使shell脚本对用户可执行