Html file inside jar

Discussion in 'Java' started by Setesh, Jun 1, 2005.

  1. Setesh

    Setesh Guest

    Hello,

    I've created a jar, which contains also description.html. Now in my main
    class I want to show it on the screen using JEditorPane. But to do that I
    need a path to that file (it works when I specify the whole path, like
    file:///c:/myFiles/.../description.html, but I want to make it more elastic
    and get it from jar archive).
    How can I get it??

    Greetz, setesh
     
    Setesh, Jun 1, 2005
    #1
    1. Advertising

  2. Setesh

    Real Gagnon Guest

    > I've created a jar, which contains also description.html. Now in my
    > main class I want to show it on the screen using JEditorPane. But to
    > do that I need a path to that file (it works when I specify the whole
    > path, like file:///c:/myFiles/.../description.html, but I want to make
    > it more elastic and get it from jar archive).
    > How can I get it??


    ....
    URL url = getClass().getResource("description.html");
    tp.setPage(url);
    ....

    Bye.
    --
    Real Gagnon from Quebec, Canada
    * Looking for Java or PB code examples ? Visit Real's How-to
    * http://www.rgagnon.com/howto.html
     
    Real Gagnon, Jun 2, 2005
    #2
    1. Advertising

  3. Andrew Thompson, Jun 2, 2005
    #3
  4. Setesh wrote:
    > I've created a jar, which contains also description.html. Now in my main
    > class I want to show it on the screen using JEditorPane. But to do that I
    > need a path to that file (it works when I specify the whole path, like
    > file:///c:/myFiles/.../description.html, but I want to make it more elastic
    > and get it from jar archive).
    > How can I get it??


    This is an FAQ (only that this group hasn't got a Usenet FAQ for a long
    time ...):

    Look up
    Class.getResource()
    Class.getResourceAsStream()

    And if you have a lot of HTML help info to display consider using Suns
    JavaHelp extension.

    /Thomas


    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
     
    Thomas Weidenfeller, Jun 2, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lucy
    Replies:
    6
    Views:
    30,965
    steve
    Sep 7, 2004
  2. JML
    Replies:
    3
    Views:
    1,299
    Andrew Thompson
    Oct 26, 2004
  3. harry
    Replies:
    1
    Views:
    546
    Sudsy
    Nov 22, 2004
  4. Arnold Peters
    Replies:
    0
    Views:
    636
    Arnold Peters
    Jan 5, 2005
  5. muttley
    Replies:
    0
    Views:
    2,795
    muttley
    Oct 20, 2005
Loading...

Share This Page