title: JavaFX WebView: HTML loading css/images from resources folder
body: <p>I am using a JavaFX <code>WebView</code> to display HTML help:</p>
  
  <pre><code>import javafx.scene.layout.BorderPane;
  import javafx.scene.web.WebEngine;
  import javafx.scene.web.WebView;
  
  import java.net.URL;
  
  public final class HelpPane extends BorderPane {
  
      private static final String HELP_RESOURCE_NAME = "/help/main.html";
  
      public HelpPane() {
          WebView webView = new WebView();
          WebEngine webEngine = webView.getEngine();
          URL url = HelpPane.class.getResource(HELP_RESOURCE_NAME);
          webEngine.load(url.toExternalForm());
  
          setCenter(webView);
      }
  
  }
  </code></pre>
  
  <p>The <code>main.html</code>, a <code>style.css</code> and various images all reside in a <code>help</code> folder inside <code>resources</code> :</p>
  
  <p><a href="https://i.stack.imgur.com/j7nvH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j7nvH.png" alt="enter image description here"></a></p>
  
  <p>From <code>main.html</code>, I am using relative links to load CSS and images:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"/&gt;
      &lt;link rel="stylesheet" href="style.css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Help&lt;/h1&gt;
  
  &lt;img src="img/main-vs-side-panels.png" width="600px"/&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Everything works perfectly fine on OSX (both, when launching from IDE and from a jar). <strong>On Windows, when launching from jar, the CSS and img links are no longer resolved</strong> (launching from IDE works fine).</p>
  
  <p>Is there a better aka more robust way for linking to resources?</p>