0

I am using a JavaFX WebView to display HTML help:

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);
    }

}

The main.html, a style.css and various images all reside in a help folder inside resources :

enter image description here

From main.html, I am using relative links to load CSS and images:

<html>
<head>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="style.css"/>
</head>
<body>
<h1>Help</h1>

<img src="img/main-vs-side-panels.png" width="600px"/>

</body>
</html>

Everything works perfectly fine on OSX (both, when launching from IDE and from a jar). On Windows, when launching from jar, the CSS and img links are no longer resolved (launching from IDE works fine).

Is there a better aka more robust way for linking to resources?

1 Answer 1

1

Turns out this is caused by an actual bug. Everything works fine with the latest JRE 1.8.0_92.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.