Skip to content
Snippets Groups Projects
Commit ffb81b30 authored by tcarver's avatar tcarver
Browse files

fix for Java 7 on Mac OSX

parent ee34fab2
Branches
Tags
No related merge requests found
...@@ -40,22 +40,16 @@ import java.io.IOException; ...@@ -40,22 +40,16 @@ import java.io.IOException;
public class BrowserControl public class BrowserControl
{ {
// The default system browser under windows. // The default system browser under windows.
private static final String WIN_PATH = "rundll32"; private static final String WIN_PATH = "rundll32";
// The flag to display a url. // The flag to display a url.
private static final String WIN_FLAG = "url.dll,FileProtocolHandler"; private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
// The default browser under unix.
private static final String UNIX_PATH = "netscape";
// The flag to display a url.
private static final String UNIX_FLAG = "-remote openURL"; private static final String UNIX_FLAG = "-remote openURL";
private static final String MAC_PATH = "/usr/bin/open"; private static final String MAC_PATH = "/usr/bin/open";
/** /**
* Display a file in the system browser. If you want to display a * Display a file in the system browser. If you want to display a
* file, you must include the absolute path name. * file, you must include the absolute path name.
*
* @param url the file's url (the url must start with either "http://" * @param url the file's url (the url must start with either "http://"
* or "file://"). * or "file://").
*/ */
...@@ -77,7 +71,6 @@ public class BrowserControl ...@@ -77,7 +71,6 @@ public class BrowserControl
} }
else else
{ {
String[] browsers = String[] browsers =
{ {
"x-www-browser", "mozilla", "firefox", "opera", "konqueror", "x-www-browser", "mozilla", "firefox", "opera", "konqueror",
...@@ -88,15 +81,22 @@ public class BrowserControl ...@@ -88,15 +81,22 @@ public class BrowserControl
{ {
ExternalApplication exApp = new ExternalApplication( ExternalApplication exApp = new ExternalApplication(
new String[] {"which", browsers[count]}, null, null); new String[] {"which", browsers[count]}, null, null);
//String stderr = exApp.getProcessStderr();
String stdout = exApp.getProcessStdout(); String stdout = exApp.getProcessStdout();
if(stdout != null && stdout.startsWith("/")) if(stdout != null && stdout.startsWith("/"))
browser = browsers[count]; browser = browsers[count];
} }
if(browser == null) if(browser == null)
{
try
{
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
}
catch(Exception e)
{
System.err.println("Could not find web browser"); System.err.println("Could not find web browser");
}
}
else else
{ {
if(browser.equals("netscape") || browser.equals("mozilla")) if(browser.equals("netscape") || browser.equals("mozilla"))
...@@ -114,7 +114,6 @@ public class BrowserControl ...@@ -114,7 +114,6 @@ public class BrowserControl
} }
} }
private static void handleNetscapeAndMozilla(final String url, final String browser) private static void handleNetscapeAndMozilla(final String url, final String browser)
throws IOException throws IOException
{ {
...@@ -142,7 +141,6 @@ public class BrowserControl ...@@ -142,7 +141,6 @@ public class BrowserControl
/** /**
* Try to determine whether this application is running under Windows * Try to determine whether this application is running under Windows
* or some other platform by examing the "os.name" property. * or some other platform by examing the "os.name" property.
*
* @return true if this application is running under a Windows OS * @return true if this application is running under a Windows OS
*/ */
public static boolean isWindowsPlatform() public static boolean isWindowsPlatform()
...@@ -156,7 +154,8 @@ public class BrowserControl ...@@ -156,7 +154,8 @@ public class BrowserControl
private static boolean isMac() private static boolean isMac()
{ {
return System.getProperty("mrj.version") != null; return System.getProperty("mrj.version") != null ||
System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment