无法运行程序“…/ abc.exe”:错误= 13,权限被拒绝


问题内容

我正在尝试执行以下代码:

       try 
        {     
            Runtime rt = Runtime.getRuntime() ;     
            Process p = rt.exec("/Users/abc/xyz.exe") ;     
            InputStream in = (InputStream) p.getInputStream() ;    
            OutputStream out = (OutputStream) p.getOutputStream();     
            InputStream err = (InputStream) p.getErrorStream() ; 
            System.out.println("in "+ in);
            System.out.println("out" + out);
            System.out.println("err" + err);
            //do whatever you want

            p.destroy() ; 
        } 
        catch(Exception e) 
        {
         /*handle exception*/
            e.printStackTrace();
            throw new Exception("Error " + e.getMessage(), e.getCause());
        }

我收到以下错误:

Cannot run program "/Users/abc/xyz.exe": error=13, Permission denied

我检查了我是否具有必要的权限,并通过终端找到了该权限:

-rw-r--r--@ 1 username  staff  4016 Nov 22 23:12 /Users/abc/xyz.exe

关于如何使它工作的任何建议?


问题答案:

您需要更改xyz.exe的权限

chmod u+x /Users/abc/xyz.exe