I have tried in many ways and searched for numerous examples, but I can not use an image in a report using iReport on a different pc than the system is doing.
My structure:
In the iReport Report: I have a parameter set to InputStream
called "logo". And an image receiving in Image Expression the parameter: $P{logo}
, in type expression class is set to java.io.inputStream
. The image you want to load into the form is called: logo.jpg and is in the same report folder: ./src/rela/logo.jpg
.
In my Java class the code snippet:
HashMap (String, Object) filtro = new HashMap(String, Object)();
filtro.put("mesNascimento", mes);
String fileName = "logo.png";
InputStream imgPath = new FileInputStream("./src/rela/"+fileName);
filtro.put("logo", imgPath);
String Endereco = "/rela/TesteComImagem.jasper";
InputStream Caminho = getClass().getResourceAsStream(Endereco);
JasperPrint jp = JasperFillManager.fillReport(Caminho, filtro, conexao);
This is one of the examples I tested. This works on the machine I'm programming, but the Java executable running on another PC does not find the logo.jpg image.