I have an executable file (ffmpeg) that I'm trying to run with a Java program on a Mac. I used the Java program to send the command chmod 777 /path/to/ffmpeg
, but when I try to run ffmpeg, I get the following error:
java.io.IOException: Cannot run program "/Users/james/WalkTheHall/ffmpeg": error=13, Permission denied
But when I run chmod 777 /path/to/ffmpeg
from Terminal on my own before opening the Java application, the command to ffmpeg will run just fine in the Java program.
Is there a difference between calling chmod
from within the Java program and calling it on my own? Why will it not work? Thank you!
I just had the same problem in my code. i solved this by add waitFor after exec. The "chmod" process is not finished when next command is executed. the code may look like:
p = Runtime.getRuntime.exec("chmod 777 xxx");
p.waitFor();
Runtime.getRuntime.exec("./xxx");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With