From: David Darby <email@hidden>
> I'm trying to write a double clickable java application (Mac OS version
> only required) that will send a command to the shell to start a bundled
> java application using a command line option (in this case it's over a
> network to run in "client" rather than the default "admin" mode). My
> attempts using Runtime.exec(cmdArray) have failed. It's easy to set up
> strings in cmdArray that will open my application using the full
> pathname (ie "open", "<filepath>" in cmdArray) as long as I point the
> filepath to the JavaApplicationStub, but open does not appear to
> support command line options (ie "-client").
I think you should be able to just open the bundle .app?
'man open' might be helpful.
Greg Guerin details on his pages how to set the bundle properties to a shell script executable that turns around and invokes the JavaApplicationStub. A neat and possibly handy trick here.
Assumption as well is that you mean Mac OS X and not Mac OS.
> I can't work out how to call the shell within the String[] of cmdArray.
> Perhaps this is trivial but I'm not particularly good at unix. Also, I
> don't want (if possible) to open Terminal and a visible command shell
> which is unsightly and the user would have to quit it each time. (I can
> do the latter simply with a runmacclient.command script made
> executable).
The following below is the shell command from my Combined application. The gist is you Runtime /bin/sh. The rest is sort of how my application wraps Runtime invocations for you if you choose to use it. IOW bit of a plug for my application although its just free stuff I've messed with.
Other stray thoughts that may or may not be of any use would be that Terminal itself is AppleScriptable. You might be better off with a small AppleScript than a java application for this. Or as Greg Guerin has been pointing out. You can also directly run small AppleScript's with the OSA commands via Runtime which might be of some use to you.
import utillib.exec.ExecutableInterface;
import utillib.exec.RuntimeExecutable;
public class shell {
// -c to pass shell a command
public static void main(String [] args) {
String [] shargs;
if (args.length == 0) {
System.out.println("shell: Missing or invalid arguments");
return;
}
ExecutableInterface shellexec = new RuntimeExecutable("/bin/sh");
shellexec.exec(args);
}
}
Mike Hall mikehall at spacestar dot net
http://www.spacestar.net/users/mikehall
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden