Skip to main content

Application showDocument() method problem with a standalone application.

4 replies [Last post]
nbabb
Offline
Joined: 2005-06-29

We are running a standalone application (in a Windows only environment) and I'm trying to use the org.jdesktop.swing.Application.showDocument() method to display an html page. I generate a file URL via

Application.getURL("/test.html", this)

and the showDocument method converts the url to its external form, for example

file:/C:/work/classes/test.html

However the windows call only seems to work when I add an additional forward slash after "file:", like so.

rundll32 url.dll,FileProtocolHandler file://C:/work/classes/test.html

Of course if you paste "file:/C:/work/classes/test.html" into the browser it resolves correctly.

It seems like there's an inconsistency in how Java views a URL string and how windows interprets it when calling the url.dll directly with rundll32?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nbabb
Offline
Joined: 2005-06-29

Sorry for replying to myself, but I found the following bug

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6351751

which refers to malformed URL's in the way that I described. According to http://www.faqs.org/rfcs/rfc1738.html (section 3.10) file URL's should take the form of "file:///
".

So it seems that the default URL.toExternalForm() is not in compliance with RFC1738? Perhaps the file URL format has been broadened by one of the updated RFC's?

I put together a hack method to reform the file URL to have two forward slashes. However it seems there was a second problem which is that the call to

Runtime.getRuntime().exec();

doesn't seem to work with an array of commands. It does work though if all of the arguments are consolidated into one command string - calling "Runtime.getRuntime().exec(String string)".

rbair
Offline
Joined: 2003-07-08

> So it seems that the default URL.toExternalForm() is
> not in compliance with RFC1738? Perhaps the file URL
> format has been broadened by one of the updated
> RFC's?

Huh, I didn't ever run into this. Is there anything we can do in SwingLabs to help out with this? For example, the Application class might be able to fix malformed file URLs automatically?

nbabb
Offline
Joined: 2005-06-29

I played around with the JDIC capabilities in this area and found that using

org.jdesktop.jdic.desktop.Desktop.browse(URL url)

works as expected without any URL string modifications. It seems like they have the foundations for a robust solution for these native interfacing functions.

Which leads me to wonder what the possibilities might be for collaboration between the two groups? Why reinvent this browser opening capability in org.jdesktop.swing.Application.showDocument() when org.jdesktop.jdic.desktop.Desktop.browse() seems like a more robust implementation, at least for a standalone application (Applets and WebStart seem to use javax.jnlp.BasicService.showDocument(), yet another showDocument implementation)?

nbabb
Offline
Joined: 2005-06-29

Last posting...it seems that the JDIC Desktop API - with some modifications - has been included in Mustang.

http://weblogs.java.net/blog/georgez/archive/2005/04/jdic_features_i.html