Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 22791
131
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:
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic