Java – unable to run program “/ applications / utilities / terminal. App”: error = 13, permission denied
•
Java
I encountered a lot of complex problems when running the following code:
package practice; import java.io.IOException; public class ProgramExecutor { public static void main (String [] args){ try{ Process p = Runtime.getRuntime().exec("/Applications/Utilities/Terminal.app"); } catch (IOException e){ e.printStackTrace(); } } }
It returns the following error message:
java.io.IOException: Cannot run program "/Applications/Utilities/Terminal.app": error=13,Permission denied 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) at basicSkills.ProgramExecutor.main(ProgramExecutor.java:9) Caused by: java.io.IOException: error=13,Permission denied at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:185) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 4 more
How will I solve it This seems to be due to a permissions problem on my Mac I used the Chmod command to change the permissions in the terminal, but with little effect What else? Can I run eclipse as superuser to access this file?
Solution
Path '/ applications / utilities / terminal App 'is the path to the terminal application. It is a directory The actual executable terminal program path is:
/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
This is the path required in the exec call
Or use
open -n /Applications/Utilities/Terminal.app
Command
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码