JDK-8163098 : Relative resources with path ./file.png are not loaded from jar file
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8u102
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2016-07-31
  • Updated: 2016-10-18
  • Resolved: 2016-08-04
Related Reports
Duplicate :  
Relates :  
Description
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


Comments
Reading relative resource (preceded by ./ or ../) from a jar file is fixed JDK-8152420. Back ported fix will be available in 8u112 release. History : https://bugs.openjdk.java.net/browse/JDK-8136466 : None of the relative resource from jar loaded. https://bugs.openjdk.java.net/browse/JDK-8152420 : Failed to load relative resource which are preceded by ./ or ../
04-08-2016

Possible duplicate of JDK-8152420
03-08-2016