Html file inside jar

S

Setesh

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
 
R

Real Gagnon

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.
 
T

Thomas Weidenfeller

Setesh said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top