dreas dreas - 2 months ago 8
Java Question

cannot read image in jar file: javafx

when I build a jar file an run it, i can't see the image.
In Eclipse it is working all good.

The Image should be a Button

<effect>
<ImageInput>
<source>
<Image url="file:./images/record_by_felickzs.PNG" />
</source>
</ImageInput>
</effect>

Answer Source

that is because on eclipse the image is not packed so it is accessible the way you are doing it, however when you export a jar file the image is packed and you can not access file inside the jar that way,,, use relative path instead:

effect>
    <ImageInput>
       <source>
          <Image url="@../../images/record_by_felickzs.PNG" />
       </source>
    </ImageInput>
 </effect>