Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
523 views
in Technique[技术] by (71.8m points)

java - Cannot run program "..../abc.exe": error=13, Permission denied

I am trying to execute the following code:

       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());
        }

and I am getting the following error :

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

I checked if I have the necessary permissions and found this via terminal:

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

Any suggestions on how to get this working?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to change permission of xyz.exe

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...