I've already read this question, but still no luck.
I want to embed HTML pages with CSS files. In my project I have res
folder, in .classpath
I have <classpathentry kind="src" path="res"/>
so that my files are embedded.
|-- src
| `-- com
| `-- pkg
| `-- blahblahblah
| `-- CTLiner.java
`-- res
`-- html
|-- index.html
`-- style.css
CTLiner.java
is main class file.
URL u = CTLiner.class.getResource("/html/index.html");
System.out.println(u.toURI().toString());
webView.showPage(u);
I use this code to load index.html
. If I run this from Eclipse I get the following output
file:/home/user/workspace/CTLiner/bin/html/index.html
And
<link href="style.css" rel="stylesheet" type="text/css" />
Works great. And when I export project as Runnable JAR, code outputs: rsrc:html/index.html And CSS file isn't found.
I believe that if I move index.html
and style.css
files up-tree (can I say so?) everything will work, but is there any other soltion?