HTML files in runnable JAR [message #734477] |
Fri, 07 October 2011 22:45 |
RD Messages: 10 Registered: September 2011 |
Junior Member |
|
|
I am trying to package an HTML file in a runnable JAR.
My code to access the file:
URL url = this.getClass().getResource("XConManual.htm");
browser.setUrl(url.toString());
This works in Eclipse, but running the JAR file doesn't work.
To export, I go:
Export->Runnable JAR File (package libraries into generated JAR).
I noticed that url.toString() returns a path to my local drive where the HTML file is located.
What am I doing wrong?
[Updated on: Fri, 07 October 2011 22:46] Report message to a moderator
|
|
|
|
Re: HTML files in runnable JAR [message #734570 is a reply to message #734477] |
Sat, 08 October 2011 16:45 |
|
On Fri, 07 Oct 2011 18:45:42 -0400, RD wrote:
> I am trying to package an HTML file in a runnable JAR.
>
> My code to access the file:
> URL url = this.getClass().getResource("XConManual.htm");
> browser.setUrl(url.toString());
>
> This works in Eclipse, but the running the JAR file doesn't work.
>
> To export, I go:
> Export->Runnable JAR File (package libraries into generated JAR).
>
> I noticed that url.toString() returns a path to my local drive where the
> HTML file is located.
>
> What am I doing wrong?
As long as the HTML file is locatable on the classpath then
it should work. For a test to prove this, move the file to
the location of your class. Later if it's more convenient you
can use a path to locate it like "/the/html/classpath/file.html".
|
|
|
Re: HTML files in runnable JAR [message #735099 is a reply to message #734570] |
Mon, 10 October 2011 22:54 |
|
Unless your browser knows how to read and show an HTML file from inside a JAR file, it won't work inside a Runnable JAR. Perhaps you should clarify what you mean by "doesn't work"?
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08231 seconds