• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

opening a html file packed inside a jar

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Experts,

I have created a java swing application which has help button. When user presses the help button, I launch the native web browser in which help url is provided and opened.
Now, I m thinking to copy those help html files and pack it inside the executable jar file. I am able to create the jar with the help html files packed in the jar. Now, I want to open these packed html files when user presses the help button.

Can anyone please guide me to open the packed html file inside the jar?


thanks,
jai
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML file inside the jar won't be displayed on native browser unless you unzip it,.
Try showing HTML in Swing component
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you really need to use the "native" browser, then you must indeed unpack it to some file and then open that. You can use File.createTempFile to store the file in a temporary file; combine that with File.deleteOnExit to remove it when the application closes. You can use java.awt.Desktop to open the file afterwards. In pseudo code:

If your HTML isn't too complex, perhaps you can use a JEditorPane. The code then becomes even simpler:
 
You showed up just in time for the waffles! And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic