Reputation: 10254
Im just trying to test running a shell script thats in my project directory in Eclipse.
new ProcessBuilder("scripts/test.sh").start();
Getting this error:
java.io.IOException: Cannot run program "scripts/test.sh": CreateProcess error=2, The system cannot find the file specified
Upvotes: 1
Views: 27564
Reputation: 11949
This could be for two reasons:
test.sh
is not a binary. You should probably use bash: bash -f scripts/test.sh
-> new ProcessBuilder()("bash", "-f", new File("scripts/test.sh").getAbsoluteFile());
scripts/test.sh
does not exists, meaning the current directory is not good.You can try System.out.println(new File("scripts/test.sh").getAbsoluteFile())
to print the path Java is using.
Upvotes: 5