0

I am working in android studio in Windows and have this error after installing the app on my device.

java io IOException:Cannot run program "java" error:13, permission denied

In my program, I am executing a java command as follows:

try {

        Process su = Runtime.getRuntime().exec("java -jar <jar file> <more command code>");
        DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
        StringBuffer output = null;
        BufferedReader reader=new BufferedReader(new
                InputStreamReader(su.getInputStream()));
        String line="";
        while((line=reader.readLine())!=null){
            output.append(line+"\n");
        }
        String response=output.toString();
        AlertDialog.Builder dialog=new AlertDialog.Builder(this);
        dialog.setMessage(response);
        dialog.show();
        outputStream.writeBytes("exit");
        outputStream.flush();
    }

    catch (IOException e)
    {
        AlertDialog.Builder dialog=new AlertDialog.Builder(this);
        dialog.setMessage(e+"");
        dialog.show();

    }

I want to execute this java -jar command. And this is failing

What permissions am I missing here?

Edited to add: The required command works well from cmd. I also placed my jar file in libs folder of my app in android studio.

mentallurg
  • 4,967
  • 5
  • 28
  • 36
user
  • 1,681
  • 5
  • 18
  • 42
  • Possible duplicate of [Permission denied error in Java for chmod command](https://stackoverflow.com/questions/3085897/permission-denied-error-in-java-for-chmod-command) – Nicolás Alarcón Rapela Sep 25 '19 at 15:40
  • Thanks @NicolásAlarcónRapela. Those links do not help me much. I have edited my question. "java -jar" command needs to be executed . But what permissions needs to be added? – user Sep 25 '19 at 16:14
  • I guess this is not coding issue, and more likely to do with permissions to some folder. But I am unable to figure out which folder needs what permissions? – user Sep 26 '19 at 08:35

0 Answers0