I am building a project and need to use WebEngine class. So I have 2 projects, MainA
and SecondB
. The SecondB
project is in dependency to MainA
, so after building it SecondB
becomes a jar file in the MainA
libs folder.
Now. I need to open a abc.html
file that is under SecondB
resources. When testing it locally it works, when building an app and deploying it on server it fails (probably because it is in SecondB
jar file). So the code I am using is:
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
ClassLoader classLoader = getClass().getClassLoader();
String s = classLoader.getResource("subfolder/abc.html").toExternalForm();
webEngine.load(s);
The method classLoader.getResource("subfolder/abc.html").toExternalForm();
returns a normal url when running the code localy and something like:
file:jar:C:/Something/MainA/libs/SecondB.jar!/subfolder/abc.html
Do you have any ideas how to load this file from a jar? I tried several options I found on SO, but without success