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

Relative resources with path ./file.png are not loaded from jar file

XMLWordPrintable

    • web
    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_102"
      Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin Robertos-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      The code works fine running from eclipse (not packaged in jar file).

      The bug was reported in: https://bugs.openjdk.java.net/browse/JDK-8138773 But the fix only applied to paths that doesn't begin with '.', that is:

      This work fine:
      <img src="myfile.png">

      This DOESN'T work:
      <img src="./myfile.png">


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In the example project provided in the issue JDK-8138773, change the index.html line:

      <img src="pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">

      BY:

      <img src="./pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">

      Then run the application


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The image should appear exactly as it happens with the current path
      ACTUAL -
      The image won't appear, cannot be loaded

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      use this index.html to replace the used in the tracker JDK-8138773:

      <!DOCTYPE html>
      <html>
      <body>
      <script src="executeOnStart.js"></script>

      <h2>Spectacular Mountain</h2>
      <img src="./pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">

      </body>
      </html>

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      We can use the paths without "./" easily, but the paths with "../..." not always is easy to replace them

            ghb Guru Hb (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: