views:

307

answers:

3

If so, is there any limitation to this ability? Specifically, I need to target Mac OSX.

+2  A: 

As it turns out, they can.

Stefan Kendall
A: 

I have used this before to launch things on a windows system never tried it on a Mac though.

public void launchScript(String args)
{
    String cmd = null;
    try
    {
        cmd = getParameter(PARAM_CMD);
        System.out.println("args value : = " + args);
        System.out.println("cmd value : = " + cmd);
        System.out.println("Full command:  = " + cmd + " " + args);
        if (cmd != null && !cmd.trim().equals(""))
        {
            if (args == null || args.trim().equals(""))
            {
                final String tempcmd = cmd;
                AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                try
                {
                    Runtime.getRuntime().exec(tempcmd);
                }
                catch (Exception e)
                {
                    System.out.println("Caught exception in privileged block, Exception:" + e.toString());
                }
                return null; // nothing to return
            }
            });                    
                System.out.println(cmd);
            }
            else
            {
                final String tempargs = args;
                final String tempcmd1 = cmd;
                AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() 
                    {
                        try
                        {
                            Runtime.getRuntime().exec(tempcmd1 + " " + tempargs);
                        }
                        catch (Exception e)
                        {
                            System.out.println("Caught exception in privileged block, Exception:" + e.toString());
                        }
                        return null; // nothing to return
                    }
                });                        
                System.out.println(cmd + " " + args);
            }
        }
        else
        {
            System.out.println("execCmd parameter is null or empty");
        }
    }
    catch (Exception e)
    {
        System.out.println("Error executing command --> " + cmd + " (" + args + ")");
        System.out.println(e);
    }
}
Knife-Action-Jesus
A: 

The only related issue I know about is that using the old "classic" PlugIn in Internet Explorer on Windows Vista, the applet was run in a "low integrity" process, which stopped it being particularly useful.

As ever, my usual advice is to know what you are doing before signing any code.

Tom Hawtin - tackline
Yeah. I need to target macs explicitly, so this isn't an issue. Good to know, though.
Stefan Kendall
Come to think about it, the OS X's "seat belt" could perhaps be applied to a browser and cause problems. I'm not entirely sure where Apple is on in adopting PlugIn 2.
Tom Hawtin - tackline