1 5 package org.h2.util; 6 7 import java.io.IOException ; 8 9 public class StartBrowser { 10 11 public static void openURL(String url) { 12 String 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 " + url); 20 } else { 21 System.out.println("Please open a browser and go to "+ url); 22 } 23 } catch (IOException 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 |