1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.shell;
26
27 import java.lang.reflect.Method;
28
29 import org.xerial.util.log.Logger;
30
31
32
33
34
35
36
37
38
39
40 public class WebBrowser {
41
42 private static Logger _logger = Logger.getLogger(WebBrowser.class);
43
44 public static void openURL(String url) {
45 try {
46 OSType osType = OSType.getOSType();
47 switch (osType) {
48 case MacOS:
49 Class fileMgr = Class.forName("com.apple.eio.FileManager");
50 Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
51 openURL.invoke(null, new Object[] { url });
52 break;
53 case Windows:
54 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
55 break;
56 default:
57
58 String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
59 String browser = null;
60 for (int count = 0; count < browsers.length && browser == null; count++)
61 if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
62 browser = browsers[count];
63 if (browser == null)
64 throw new Exception("Could not find web browser");
65 else
66 Runtime.getRuntime().exec(new String[] { browser, url });
67 break;
68 }
69 }
70 catch (Exception e) {
71 _logger.error(e);
72 }
73 }
74
75 }