From 3e380c51b623b2f8efbee76f9018364c87952d69 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 16 Feb 2011 14:53:47 +0000 Subject: [PATCH] update to browser start with linux git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7486 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/gui/framework/Browser.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/source/net/yacy/gui/framework/Browser.java b/source/net/yacy/gui/framework/Browser.java index f4ba82243..800f458db 100644 --- a/source/net/yacy/gui/framework/Browser.java +++ b/source/net/yacy/gui/framework/Browser.java @@ -83,7 +83,11 @@ public class Browser { if (systemOS == systemMacOSX) { openBrowserMac(url); } else if (systemOS == systemUnix) { - openBrowserUnix(url); + try { + openBrowserUnixGeneric(url); + } catch (Exception e) { + openBrowserUnixFirefox(url); + } } else if (systemOS == systemWindows) { openBrowserWin(url); } else { @@ -107,18 +111,21 @@ public class Browser { private static void openBrowserMac(final String url) throws Exception { Process p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""}); 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 + ")"; Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); - if (p.exitValue() != 0) { - cmd = "/etc/alternatives/www-browser " + url; - p = Runtime.getRuntime().exec(cmd); - // no error checking, because it blocks until firefox is closed - } + if (p.exitValue() != 0) throw new RuntimeException("Unix Exec Error/Firefox: " + errorResponse(p)); + } + + 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 {