Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8089600

[WebView] local images not loaded when web page is loaded from jar file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u25
    • javafx
    • Mac OS X 10.9.5, x86_64
      JavaFx 8.0.25-b17

    • web

      I'm trying to develop a desktop application that should load images from local file system.
      Here after is a sample application that uses various way to do that (loading from jar, file and resources).

      In netbeans
      A) Right click on the project -> "run" -> only the image 1 and 2 are loaded
      B) Right click on the main project file -> "run file" -> there all loaded except 4

      I'm really wondering what's happening here ?

      ------------------------------------------------------------
      TestWebEngine.java (in a package test)
      ------------------------------------------------------------
      package test;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class TestWebEngine extends Application {
          @Override public void start(Stage stage) {
              WebView webView = new WebView();
              WebEngine webEngine = webView.getEngine();
              webEngine.load(getClass().getResource("/index.html").toExternalForm());
              stage.setScene(new Scene(webView, 1280, 900));
              stage.show();
          }
          public static void main(String[] args) {
              launch(args);
          }
      }

      ------------------------------------------------------------
      index.html (in the root project folder)
      ------------------------------------------------------------
      <!doctype html>
      <html lang="en">
        <head>
            <title>LOAD LOCAL IMAGES</title>
        </head>
        <body>
          <img src="test.png" alt="test1"/>
          <img src="jar:file:///Users/Badisi/test.jar!/test.png" alt="test2"/>
          <img src="file:/Users/Badisi/test.png" alt="test3"/>
          <img src="file://Users/Badisi/test.png" alt="test4"/>
          <img src="file:///Users/Badisi/test.png" alt="test5"/>
        </body>
      </html>

      ------------------------------------------------------------
      test.png (in the root project folder)
      ------------------------------------------------------------

        1. Test.zip
          171 kB
        2. screenshot-win8x64.png
          screenshot-win8x64.png
          102 kB
        3. screenshot-mac10.10.png
          screenshot-mac10.10.png
          79 kB

            Unassigned Unassigned
            badisijfx Badisi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported: