Skip to main content

how to open a file with JDIC packaged inside my jar?

2 replies [Last post]
anilp1
Offline
Joined: 2006-03-20
Points: 0

I have an html file help.html packed inside myapp.jar which is distributed and installed via Java Web Start.

URL helpFileUrl = MyApp.class.getResource("help.html");
Desktop.browse(helpFileUrl);

throws a Desktop exception.
org.jdesktop.jdic.desktop.DesktopException: No default browser associated with this URL

It is resolving the url to foo.com/myapp.jar

Any help appreciated.
thanks,
Anil

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
anilp1
Offline
Joined: 2006-03-20
Points: 0

I also tried

File f = new File(NodePad.helpFileUrl.toURI());
Desktop.open(f);

I get an exception: URI file is not hierarchical.
I shall try copying the file from the jar to the user's home directory, but it would have been nice to open it from the jar - suppose the user deletes the html file?

anilp1
Offline
Joined: 2006-03-20
Points: 0

> I shall try copying the file from the jar to the
> user's home directory, but it would have been nice to
> open it from the jar - suppose the user deletes the
> html file?

this worked, but again, would've been nice to

> open it from the jar - suppose the user deletes the
> html file?