金子邦彦研究室プログラミングJava のプログラム例getRuntime サンプルプログラム

getRuntime サンプルプログラム

IE を起動して,所定のWebページを表示する.

package is.kyushu.u.ac.jp;

import java.io.IOException;

public class Browser {
    
    private static String browser = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
    public static void main(String args[])
    {
        open("http://www.yahoo.co.jp");
    }
    public static void open(String urlString) {
        try {
            Runtime.getRuntime().exec(new String[] {browser, urlString});
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}