update to browser start with linux

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7486 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 4473cf8c61
commit 3e380c51b6

@ -83,7 +83,11 @@ public class Browser {
if (systemOS == systemMacOSX) { if (systemOS == systemMacOSX) {
openBrowserMac(url); openBrowserMac(url);
} else if (systemOS == systemUnix) { } else if (systemOS == systemUnix) {
openBrowserUnix(url); try {
openBrowserUnixGeneric(url);
} catch (Exception e) {
openBrowserUnixFirefox(url);
}
} else if (systemOS == systemWindows) { } else if (systemOS == systemWindows) {
openBrowserWin(url); openBrowserWin(url);
} else { } else {
@ -107,18 +111,21 @@ public class Browser {
private static void openBrowserMac(final String url) throws Exception { private static void openBrowserMac(final String url) throws Exception {
Process p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""}); Process p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""});
p.waitFor(); p.waitFor();
if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p)); if (p.exitValue() != 0) throw new RuntimeException("Mac Exec Error: " + errorResponse(p));
} }
private static void openBrowserUnix(final String url) throws Exception { private static void openBrowserUnixFirefox(final String url) throws Exception {
String cmd = "firefox -remote openURL(" + url + ")"; String cmd = "firefox -remote openURL(" + url + ")";
Process p = Runtime.getRuntime().exec(cmd); Process p = Runtime.getRuntime().exec(cmd);
p.waitFor(); p.waitFor();
if (p.exitValue() != 0) { if (p.exitValue() != 0) throw new RuntimeException("Unix Exec Error/Firefox: " + errorResponse(p));
cmd = "/etc/alternatives/www-browser " + url;
p = Runtime.getRuntime().exec(cmd);
// no error checking, because it blocks until firefox is closed
} }
private static void openBrowserUnixGeneric(final String url) throws Exception {
String cmd = "/etc/alternatives/www-browser " + url;
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
if (p.exitValue() != 0) throw new RuntimeException("Unix Exec Error/generic: " + errorResponse(p));
} }
private static void openBrowserWin(final String url) throws Exception { private static void openBrowserWin(final String url) throws Exception {

Loading…
Cancel
Save