From: segalsegal on
It has been a long time since one could rely on showDocument opening a
new browser window because browsers have needed to defend against pop-
ups. However, those of us using digitally signed applets were able to
use code such as that shown below to use Runtime.exec to do the same
thing.

Recently, however, we've been getting reports from users of our large
applet that for some people using Internet Explorer the code no longer
works on Windows XP and Vista. I've tested various configurations of
Internet Explorer on XP and Vista and not run into this limitation;
i.e. the showInBrowser code below works fine.

I'm wondering whether there are settings that would cause this code to
fail. Does anyone have any ideas?

final static void showInBrowser(URL url)
{
try
{
if (microsoftBrowser && windowsOS) Runtime.getRuntime().exec
("iexplore.exe " + url);
else if (firefoxBrowser && windowsOS) Runtime.getRuntime().exec
("firefox.exe \"" + url + "\"");
else if (macOS)
{
if (firefoxBrowser) Runtime.getRuntime().exec(new String[] {"open",
"-a", "Firefox.app", url.toString()});
else if (safariBrowser) Runtime.getRuntime().exec(new String[]
{"open", "-a", "Safari.app", url.toString()});
else Runtime.getRuntime().exec(new String[] {"open", url.toString
()});
}
else appletContext.showDocument(url, "_blank");
}
catch (Exception e)
{
System.out.println("Couldn't show in browser: " + e);
}
}
From: RedGrittyBrick on
segalsegal wrote:
> I'm wondering whether there are settings that would cause this code to
> fail. Does anyone have any ideas?
[...]
> if (microsoftBrowser && windowsOS) Runtime.getRuntime().exec
> ("iexplore.exe " + url);
> else if (firefoxBrowser && windowsOS) Runtime.getRuntime().exec
> ("firefox.exe \"" + url + "\"");
> else if (macOS)

On Windows, can't you execute an .html file and expect the OS to use
it's file-associations to work out which browser is installed?

[...]
> catch (Exception e)

Have you considered catching more specific exceptions?

> {
> System.out.println("Couldn't show in browser: " + e);
> }
> }

Is that useful?

I'd log the exception (and preferably a stack trace) to a file that can
be attached by the end-user to an email.

--
RGB
From: jolz on
> if (microsoftBrowser && windowsOS) Runtime.getRuntime().exec
> ("iexplore.exe " + url);

I don't see how it can work if iexplore.exe isn't in the PATH and
browser isn't started from directory containing iexplore.exe.

Doesn't java.awt.Desktop work for you?
From: Roedy Green on
On Tue, 19 Jan 2010 12:11:08 -0800 (PST), segalsegal
<googlegroups(a)segal.org> wrote, quoted or indirectly quoted someone
who said :

>I'm wondering whether there are settings that would cause this code to
>fail. Does anyone have any ideas?

which of the branches is failing? all execs?
--
Roedy Green Canadian Mind Products
http://mindprod.com
Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question.
~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming .
From: Roedy Green on
On Tue, 19 Jan 2010 12:11:08 -0800 (PST), segalsegal
<googlegroups(a)segal.org> wrote, quoted or indirectly quoted someone
who said :

>("iexplore.exe " + url);
> else if (firefoxBrowser && windowsOS) Runtime.getRuntime().exec
>("firefox.exe \"" + url + "\"");

how come you put Firefox's url in quotes but not iexplore's.

what does your url look like?

--
Roedy Green Canadian Mind Products
http://mindprod.com
Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question.
~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming .