KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > util > StartBrowser


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.util;
6
7 import java.io.IOException JavaDoc;
8
9 public class StartBrowser {
10     
11     public static void openURL(String JavaDoc url) {
12         String JavaDoc osName = System.getProperty("os.name");
13         try {
14             if(osName.startsWith("Windows")) {
15                 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
16             } else if(osName.startsWith("Mac OS X")) {
17                 // Runtime.getRuntime().exec("open -a safari " + url);
18
// Runtime.getRuntime().exec("open " + url + "/index.html");
19
Runtime.getRuntime().exec("open " + url);
20             } else {
21                 System.out.println("Please open a browser and go to "+ url);
22             }
23         } catch (IOException JavaDoc e) {
24             System.out.println("Failed to start a browser to open the url " + url);
25             e.printStackTrace();
26         }
27     }
28
29 }
30
Popular Tags