0

i have developed an invoice generate program. each pdf invoice include an image on top left corner, when i run the application on someone else's machine(not the developed machine), it doesn't show the image on top left corner of the pdf.

this is how I read the image:

Image companyLogo = Image.getInstance("images/amadeus14.png");

This is my option 1

within the project i have created a package and inside it i have made a folder called image. inside that folder i have put that image file and tried to access it in my program.

Image companyLogo = Image.getInstance("Resources/Images/HemasLogo.jpg");

this is my option 2 option

but it gives an error saying

java.io.FileNotFoundException: C:\Users\businesssupport\Documents\NetBeansProjects\invoiceGenerator\Resources\HemasLogo.jpg (The system cannot find the path specified)

G.I.Joe
  • 77
  • 1
  • 2
  • 10

1 Answers1

1

Looking at your previous questions this and this,

  • you must know you're trying to read from current working directory (you can find it using System.getProperty("user.dir")) )
  • It is not a webapp.
  • You cannot use shared (FTP) folders

So, I can see 2 options:

  1. to put the image inside a package before packing the application, then you will be able to read it from any computer without making any changes

    Check Including Images with an executable jar


  1. Use a local folder. You will need to create a common folder for each installed computer, then manually copy the image on each computer, and read it like

     Image companyLogo = Image.getInstance("C:\\myApp\\images\\amadeus14.png");
    
Community
  • 1
  • 1
joc
  • 1,336
  • 12
  • 31
  • 1
    In addition to this, if OP is using iText it's also useful to have a look at [this question about PDF images](http://stackoverflow.com/questions/15742125/getting-image-from-drawable-and-adding-to-pdf-using-itext) – px06 Aug 24 '16 at 08:50