
MacOS support の予定

LightSpeed Chat の tarchan さんに感謝します。


19:38 tarchan System.getProperty("mrj.version");
19:38 tarchan これでMRJのバージョンが調べられます。

MRJToolkitStubs.zip

openURL
http://developer.apple.com/qa/java/java12.html

import java.awt.Frame;
import java.awt.FileDialog;
import java.io.File;
import java.io.IOException;
import com.apple.mrj.MRJFileUtils;
public class ExecTest extends Frame
{
    public static void main(String[ ] args){
        new ExecTest();
        System.exit(0);
    }

    public ExecTest(){
        String url = "http://developer.apple.com/java/";
        try{
						//Attempt to let MRJ do all the work for us.
          	MRJFileUtils.openURL(url);
            //If this was successful, then we need not go on.
            return;
        }catch (IOException exc){
            //This can occur if problems arise while attempting
            //to open the URL.
        }catch (NoSuchMethodError err){
            //This can occur when earlier versions of MRJ are used which
           //do not support the openURL method.
       }catch (NoClassDefFoundError err){
         //This can occur under runtime environments other than MRJ.
       }

        //If we make it here, MRJ was unsuccessful in opening the URL, and
        //we need to do it the hard way, using Runtime.exec.
				String browserName;
				//Set up a FileDialog for the user to locate the browser to use.
				FileDialog fileDialog = new java.awt.FileDialog(this);
        fileDialog.setMode(FileDialog.LOAD);
        fileDialog.setTitle("Choose the browser to use:");
        fileDialog.setVisible(true);

   //Retrieve the path information from the dialog and verify it.
     String resultPath = fileDialog.getDirectory();
     String resultFile = fileDialog.getFile();
     if( resultPath != null &&  resultPath.length()!= 0 
     &&  resultFile != null && resultFile.length() != 0
     ){
					File file = new File(resultPath + resultFile);
					if(file != null){
						browserName = file.getPath();
						try{
							Runtime.getRuntime().exec(new String[] {browserName, url});
						}catch (IOException exc){
							exc.printStackTrace();
						}
					}
			}
	}
}
