Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: runtime.exec



From: David Rocks <email@hidden>  
 

> The script statement 
> tell application "Safari" to open location "file:/Macintosh HD/Users/rocks/home.html" 

> works with all the browsers but with different results. 

You might try variations on the URL. I guess I'm thinking of something like file:///Macintosh HD/Users/rocks/home.html or file://localhost/Macintosh HD/Users/rocks/home.html

Your other choice for LaunchServices would be JNI. JNIDirect my variation of that.
Like...

	// Open specific app path passed with also passed file or url
	public static String open(String apppath,String fileorurl) {
		if (fileorurl.indexOf(":") > -1) {
			CFString urlstring = new CFString(fileorurl);
			int urlref = CFURLFunctions.CFURLCreateWithString(0,urlstring.getCFStringRef(),0);
			int isDirectory = 0;
			if (new File(apppath).isDirectory()) isDirectory = 1;
			CFString appurl = new CFString(apppath);
			int appurlref = CFURLFunctions.CFURLCreateWithFileSystemPath(0,appurl.getCFStringRef(),
												kCFURLPOSIXPathStyle,isDirectory);
			int result = launchIt(appurlref,urlref,kLSLaunchDontSwitch | kLSLaunchNoParams | kLSLaunchAsync | kLSLaunchStartClassic);
		}
		else {
			FSRef appref = new FSRef(apppath);
			launchIt(appref,null,kLSLaunchDontSwitch | kLSLaunchNoParams | kLSLaunchAsync | kLSLaunchStartClassic);
		}
		return apppath;
	}

or....

	public static File findByUrl(String url,boolean launch,File document) throws FileNotFoundException {
		int [] urlOutRef = new int[1];
		int status = openURL(url,urlOutRef);
		try {
			JDirectLocking.acquire();
			if (status != noErr) {
				CFBundleFunctions.CFRelease(urlOutRef[0]);
				throw new FileNotFoundException("findApplication: openURL " + url + " - err " + status);
			}
			int stringRef = CFURLCopyPath(urlOutRef[0]);
			CFBundleFunctions.CFRelease(urlOutRef[0]);
			return new File(new CFString(stringRef).toString());
		}
		catch (Exception ex) { ex.printStackTrace(); }
		finally { JDirectLocking.release(); }
		return null;
	}

Both from my macnative.jnidirect.SignatureToApp 
JNIDirect class library if of interest.

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

References: 
 >Re: runtime.exec (From: Marc Epard <email@hidden>)
 >Re: runtime.exec (From: David Rocks <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.