Sam
Sam

Reputation: 59

Executing and Terminating any app of OSX using java

I'm trying to develop a desktop application that allows user to launch some of the applications (iTunes, terminal, calculator...) of Mac OSX using Java. I am new to OSX and I don't really know how the file system of the mac OSX works. I used

Runtime.getRuntime().exec("/usr/bin/open -a Terminal");

in order to execute terminal, but I ended up with no luck. I would really appreciate if anyone can help me solve this problem.

PS. if anyone has any idea on how to close the application that would be a great help.

I've attached the details of the system I'm working on. Details of my system

Upvotes: 1

Views: 79

Answers (1)

Mark Bessey
Mark Bessey

Reputation: 19782

Well, that's almost right, except that "open" expects to be passed the full name of the application, like iTunes.app.

this works:

public class HelloWorldApp {
    public static void main(String[] args) throws Exception{
    Runtime.getRuntime().exec("/usr/bin/open -a iTunes.app");
    }
}

Upvotes: 1

Related Questions