Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Html file inside jar (http://www.velocityreviews.com/forums/t143902-html-file-inside-jar.html)

Setesh 06-01-2005 09:38 PM

Html file inside jar
 
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



Real Gagnon 06-02-2005 12:42 AM

Re: Html file inside jar
 
> 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

Andrew Thompson 06-02-2005 02:00 AM

Re: Html file inside jar
 
On Wed, 1 Jun 2005 23:38:23 +0200, Setesh wrote:

> I've created a jar, which contains also description.html.

....
> How can I get it??


<http://www.physci.org/codes/javafaq.jsp#path>

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Thomas Weidenfeller 06-02-2005 06:55 AM

Re: Html file inside jar
 
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/...g/java/gui/faq


All times are GMT. The time now is 09:03 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.