/** * Launches the operating system executable associated with the file or URL (http:// or https://). * If the file is an executable then the executable is launched. The program is launched with the * specified working directory only when the <code>workingDir</code> exists and <code>fileName * </code> is an executable. Note that a <code>Display</code> must already exist to guarantee that * this method returns an appropriate result. * * @param fileName the file name or program name or URL (http:// or https://) * @param workingDir the name of the working directory or null * @return <code>true</code> if the file is launched, otherwise <code>false</code> * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT when fileName is null * </ul> * * @since 3.6 */ public static boolean launch(String fileName, String workingDir) { if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); NSAutoreleasePool pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { if (workingDir != null && isExecutable(fileName)) { try { Compatibility.exec(new String[] {fileName}, null, workingDir); return true; } catch (IOException e) { return false; } } NSURL url = getURL(fileName); NSWorkspace workspace = NSWorkspace.sharedWorkspace(); return workspace.openURL(url); } finally { pool.release(); } }