Issue
I have been searching the forum for answers and similar posts, but none have helped me resolve my issue.
I am working on a standalone project - no server involved. And am trying to load a html file present inside a jar file into a JavaFX Webview using a code similar to the following
webView.getEngine()
.load(this.getClass().getResource("htmlInsideJar.html").toExternalForm());
The page loads into the webView, but the associated JS and CSS files are not loading into the HTML page.
However the HTML page loads just fine with all associated css and js files when loaded directly from disk
webView.getEngine()
.load("htmlFromDiskDirectly.html").toString());
I am using same file-folder structure for files with html, css and js contents.
The java version that I am using is as follows java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode)
Any help would be deeply appreciated please.
Thanks
Solution
I have found a fix to this issue. I am using requireJs to load my scripts into the html page. While the page loaded perfectly fine in
- IE
- firefox
- chrome
- and even in eclipse's inbuilt web browser
the JavaFX web engine precisely caught few errors where I had mis-spelt a file dependency in a require statement.
I had used some thing like require(['../abcModule/FileDependecy'] .... instead of require(['../abcModule/fileDependecy']. Changing a couple of such stuffs fixed the issue and the page loaded successfully. Had to spend 3 + hours to find a fix for it. grrr –
Thanks to fire-bug lite. Though it does not load neatly inside the JavaFx webview, I was able to mine the error info from the coarse data that appeared to get the issue fixed.
Hope this helps some one
Answered By - kathikeyan A
Answer Checked By - David Goodson (JavaFixing Volunteer)