1 22 23 package apollo.dev.browser.spencer; 24 25 import java.io.*; 26 import java.net.*; 27 import houston.*; 28 29 public class BrowserLauncher 30 { 31 32 35 private final static String UNIX_FLAG = "-remote openURL"; 36 37 40 private final static String UNIX_PATH = "netscape"; 41 42 45 private final static String WIN_FLAG = "url.dll,FileProtocolHandler"; 46 47 50 private final static String WIN_ID = "Windows"; 51 54 private final static String WIN_PATH = "rundll32"; 55 56 public static boolean isWindowsPlatform() 57 { 58 String os = System.getProperty( "os.name" ); 59 60 if( os != null && os.startsWith( WIN_ID ) ) 61 return true; 62 else 63 return false; 64 } 65 66 public static void showDocument( String url ) 67 { 68 if( url == null ) 69 return; 70 71 boolean windows = isWindowsPlatform(); 72 String cmd = null; 73 74 try 75 { 76 if( windows ) 77 { 78 cmd = WIN_PATH + " " + WIN_FLAG + " " + url; 80 Process p = Runtime.getRuntime().exec( cmd ); 81 } 82 else 83 { 84 89 cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")"; 91 Process p = Runtime.getRuntime().exec( cmd ); 92 93 try 94 { 95 int exitCode = p.waitFor(); 98 99 if( exitCode != 0 ) 100 { 101 cmd = UNIX_PATH + " " + url; 104 p = Runtime.getRuntime().exec( cmd ); 105 } 106 } 107 catch( InterruptedException x ) 108 { 109 Status.error( "*** failed to bring up browser using command '" + cmd + "': " + x.toString() ); 110 } 111 } 112 } 113 catch( IOException x ) 114 { 115 Status.error( "*** failed to bring up browser using command '" + cmd + "': " + x.toString() ); 117 } 118 } 119 } 120 | Popular Tags |