0

I'm losing images of my project after creating a jar file, although they work just fine on eclipse

i have tried this code bellow to import an image to a Jbutton

valid = new javax.swing.JButton(new ImageIcon(((new ImageIcon("/resources/cashier-machine.png")).getImage())
             .getScaledInstance(170, 170, java.awt.Image.SCALE_SMOOTH)));

i'm still failing to get images after creating a Jar file for the project

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Fennec
  • 13
  • 4
  • 2
    Application resources will become embedded resources by the time of deployment, so it is wise to start accessing them as if they were, right now. An [tag:embedded-resource] must be accessed by URL rather than file. See the [info. page for embedded resource](http://stackoverflow.com/tags/embedded-resource/info) for how to form the URL. – Andrew Thompson Jun 03 '19 at 11:58
  • 1
    `getScaledInstance(170, 170, java.awt.Image.SCALE_SMOOTH)` Rescale images before they are put into the Jar. It's faster and results in a better image (generally). – Andrew Thompson Jun 03 '19 at 11:59

0 Answers0