0

I am trying to start the terminal and run a command automatically by using Runtime.getRuntime().exec(), but it gives me following exceptions:

java.io.IOException: Cannot run program "/Applications/Utilities": error=13, Permission denied

I found the terminal app and changed permission to read&write since I have the administrator account, but it still gives me the same exception.

I tried to open other document on my mac using the same way, it shows up to have the same exception. Is there any other way I can execute commands on terminal at runtime?

Here is the code I have :

import java.io.IOException;

public class OpenTerminal {

    public static void main(String[] args) {

        OpenTerminal ot = new OpenTerminal();
        try {
            Runtime.getRuntime().exec("/Applications/Utilities open - a Terminal");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
blo0p3r
  • 6,790
  • 8
  • 49
  • 68
  • 1
    `/Applications/Utilities open - a Terminal` is not a valid shell command, so thats not going to work regardless. Try `open -a Terminal` instead. – Perception Feb 07 '13 at 20:20

1 Answers1

0

/Applications/Utilities is a directory. You can't execute it.

bmargulies
  • 97,814
  • 39
  • 186
  • 310