I'm trying to set the src of an img tag I have dynamically. The following piece of code works when running from eclipse but not after exporting it as a running jar file:
doc.getElementById("user-thumb").setAttribute("src", selectedVcard.getThumb().getFilePath());
The element got by the "user-thumb" id is an image. The thumb object returned is a simple custom ImageView I've extended to hold more information and is initialized using:
public Thumb(String url) {
super(url);
this.setFilePath(url);
getStyleClass().add("thumb");
}
the method getFilePath() is returning a path from a temporary file starting with:
file:/
But I've already tried to change it to
file://
and even:
file:///
and got no success. I have googled and searched here but every answer points to start with file://. Is there something wrong with my code or is it javafx 2? By the way, I'm using javafx 2.2 GA and the jre 1.7.0.6 from oracle. Cheers
You could use Data URI for the images
Something like ...