Works fine from a .bat file, but not from a WebStart: spawning off browser
We've got a slightly modified variant of the June 2001 version of Eric Albert's BrowserLauncher class running in one of our products, and something weird is happening with it:
If we run the jar from a .bat file, with either java.exe or javaw.exe, the "openURL()" method of BrowserLauncher works fine, and spawns off the default browser. But if we run it as a WebStart, it locks up trying to spawn off a browser.
The crucial statement appears to be:
process = Runtime.getRuntime().exec(new String[]{ (String)browser, FIRST_WINDOWS_PARAMETER, SECOND_WINDOWS_PARAMETER, THIRD_WINDOWS_PARAMETER,'"' + url +'"'});
where
FIRST_WINDOWS_PARAMETER ="/c"
SECOND_WINDOWS_PARAMETER ="start"
THIRD_WINDOWS_PARAMETER ="\"\""
and the "locateBrowser()" method has evidently set
browser ="cmd.exe"
as an apparent means of deferring to the operating system's choice of default browser.
Can anybody explain why this would work fine if the jar is launched from a .bat file, but would lock up if the jar is launched from WebStart?
# 1
Some perhaps crucial additional information:
If I feed this a normal web URL, such as http://www.hb.quik.com/jamesl/index.html
(which is a real URL), it works fine. And if I feed it the URL that causes the customer's virtual private net to cough up a page, in the general form http://mogrify.foo.com/images/scripts/cgi/detail.cgi?FOOBAR.JPG
(which actually coughs up a web page, not a JPEG image), it also works fine. But if I feed it the URL that it would normally be given, in the general form http://intranet/part?FOOBAR.JPG
which (don't ask me how or why; I don't know) turns into the "mogrify" URL when fed into a browser, it locks up.
# 3
Would You Believe?
It appears that it wasn't the call to BrowserLauncher that was blowing up, but an earlier call to the URL-based ImageIcon constructor. It seems that the redirect was locking it up, even if a HttpURLConnection.setFollowRedirect(true) had been issued beforehand. Normally, if that constructor gets something it can't understand, it comes back with no displayable image. But for some reason, if it gets a redirect (or possibly just specifically a redirect on a VPN), and it's running from a WebStart, (but not from a command line, for some reason), it locks up.
Weird.
JHHL