Skip to content Skip to sidebar Skip to footer

Javafx Webview Does Not Load Upper Folder Script In Jar

Im trying to create code editor based on JavaFX WebView. I'm loading jquery to my .html file loaded by WebView like this:

Solution 1:

The jar protocol does not allow for .. relative location specifiers.

A request to load a relative url from a resource loaded from a jar will use the same protocol as was used to load the original resource. In this case, because the original resource is loaded from a jar, the jar: protocol is used. You can find the definition of the jar protocol in the JarURLConnection class documentation.

You could use a different protocol to load the resources, e.g. http: or file:, in which case .. will work as those protocols understand ... To do so, you would need to extract the relevant resources from the jar file and host them on a web server or local file system. Which is probably not what you want.

A simpler solution is to not use .. in your html files, either by placing the items under a well-known root directory within the jar and using an absolute reference (e.g. /libs/jquery-3.1.1.js), or including the items in the same folder as the html or a subfolder of it (e.g. jquery-3.1.1.js or libs/jquery-3.1.1.js).

I know this is not the answer you wanted, but I don't have an exact solution to do precisely what you want.

Related question:

Post a Comment for "Javafx Webview Does Not Load Upper Folder Script In Jar"