Register to reply

Opening and operating programs in java on a mac

by Yoyo_Guru
Tags: java, mac osx
Share this thread:
Yoyo_Guru
#1
Jan26-11, 02:58 PM
P: 33
I started taking a java course at my school and we are required to use macs. I looked for how to open other programs like text edit or the terminal but the code segments I found only worked for java. Is it possible to have a java program open other programs like text edit or the terminal on a mac? And if so how?
Phys.Org News Partner Science news on Phys.org
Apple to unveil 'iWatch' on September 9
NASA deep-space rocket, SLS, to launch in 2018
Study examines 13,000-year-old nanodiamonds from multiple locations across three continents
Grep
#2
Jan26-11, 04:05 PM
P: 296
Quote Quote by Yoyo_Guru View Post
I started taking a java course at my school and we are required to use macs. I looked for how to open other programs like text edit or the terminal but the code segments I found only worked for java. Is it possible to have a java program open other programs like text edit or the terminal on a mac? And if so how?
I'm not entirely sure what you're asking here. You mean you want to launch some external program from Java code?

If so, the Runtime class has exec functions that can do that:

http://download.oracle.com/javase/6/docs/api/index.html

There's so many ways of doing it. And exec isn't always the best way, but it might be what you're looking for.

I found a page with a rather large number of different ways to run external programs from Java:

http://www.rgagnon.com/javadetails/java-0014.html

Not sure why you want to do that in this case, but that's up to you.
Yoyo_Guru
#3
Jan26-11, 05:12 PM
P: 33
ok, thanks. I got a little farther but everytime I run it I get an error saying permission denied. Do you know how to get around this? Also some of the terms used on the site confused me so I kinda had to guess. Here is what I wrote, maybe I just wrote something wrong.

Process p = new ProcessBuilder("/Applications/Skype.app", "myArg").start();

Grep
#4
Jan26-11, 05:46 PM
P: 296
Opening and operating programs in java on a mac

Quote Quote by Yoyo_Guru View Post
ok, thanks. I got a little farther but everytime I run it I get an error saying permission denied. Do you know how to get around this? Also some of the terms used on the site confused me so I kinda had to guess. Here is what I wrote, maybe I just wrote something wrong.

Process p = new ProcessBuilder("/Applications/Skype.app", "myArg").start();
Keep in mind that the "myArg" means you're passing the application an argument of "myArg". That was just a placeholder in the example in the docs. Unless you're trying to pass that as a parameter (don't see why), you can just remove it.

As for the permission problem, I'm not entirely sure. I assume you caught an IOException? I would guess that it's your operating system and not the Java Virtual Machine (but I could be wrong). As for how to fix it, I'm not totally sure. Someone who knows Macs will have to chime in here. There's probably some way of giving the application permission to launch Skype, but I personally have no clue how to do it on a Mac and would be reaching.
Yoyo_Guru
#5
Jan26-11, 05:48 PM
P: 33
Alright, thanks a lot.


Register to reply

Related Discussions
Operating instructions Electrical Engineering 0
Java programs Programming & Computer Science 9
Operating with dx and dy? Calculus 23
Operating Point Electrical Engineering 2
Switch not operating? Introductory Physics Homework 7