Inconsistent whether new browser window opens from signed applet

S

segalsegal

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);
}
}
 
J

jolz

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?
 
R

Roedy Green

("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?
 
R

Roedy Green

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?

Sometimes. It is iffy, requiring a proper association of the *.html
extension to the desired browser to be set up. Mine mysteriously
stopped working today.

I have posted the lore I have collected on the problem at
http://mindprod.com/jgloss/browserlaunching.html
 
R

Roedy Green

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.

Try typing iexplore.exe at the command prompt. I will launch. MAGIC!

There are three copies:

C:\Windows\winsxs\amd64_microsoft-windows-i..etexplorer-optional_31bf3856ad364e35_8.0.7600.16385_non
e_0f6595383e78c6f8\iexplore.exe

C:\Windows\winsxs\wow64_microsoft-windows-i..etexplorer-optional_31bf3856ad364e35_8.0.7600.16385_non
e_19ba3f8a72d988f3\iexplore.exe

C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE


None of these are not on the path. Huh?

Look at the pseudopath aux path entries in the registry.

See http://mindprod.com/jgloss/registry.html#AUXPATH

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\IEXPLORE.EXE

That is how MS pulls this off without requiring extra directories on
the PATH where they could easily get lost.

see http://mindprod.com/project/kicker.html
for a student project to automatically build these registry entries
and rapidly launch programs with canned sets of parameters without any
path requirements.
 
J

jolz

I don't see how it can work if iexplore.exe isn't in the PATH and
Try typing iexplore.exe at the command prompt. I will launch.

No, it won't (yes, I did try):
"NOTE: Windows uses the entries if it does not find the application in
the current PATH AND the application was launched with the
ShellExecute() function."

Maybe beacuse console use CreateProcess(Ex). JVM probably may, but
doesn't have to use ShellExecute().
 
S

segalsegal

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

The code was written years ago and presume (but can't guarantee) that
there was some good reason for the difference, but I don't remember.

I'm blocked from doing many of the usual debugging approaches because
every computer I've tried has no problem with this code. But two
users have this problem, and as detailed elsewhere in this thread, the
problem was gone today for one of the users.
 
S

segalsegal

Have you considered catching more specific exceptions?


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.

Good point. I should see if this is throwing an exception, since if
an exception is thrown, at the minimum I could then try some of the
approaches that Roedy Green details at http://mindprod.com/jgloss/browserlaunching.html.
I am a bit limited by not having been able to reproduce this problem
on any computer I've tried, and the fact that our users are medical
experts, not computer experts. But now that I have suggestions of
what to try that is different it seems worthwhile to get the doctors
to help debug this problem, assuming that it is still present (it was
gone for one of the two doctors today, as detailed elsewhere in this
thread).

I'll report back if I get more information.

Thanks for the help. It is great to know that Roedy and the others
are still as helpful as in the old days when we were all new to Java.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top