I'm trying to insert an image in Ireport 3.7.5.
When I drag the Image field to the page and place the static url with the image address, it works, but when I put it in Image Expression
like this:
System.getProperty("user.dir") + "\fotos" + "\"+$F{FOTO}
The code above generate the same address I used in the static url that works
But it gives an error:
C: \ Program Files (x86) \ Jaspersoft \ iReport-3.7.5 \ photos \ clob46: 'ICONE3.png' net.sf.jasperreports.engine.JRException: Byte data not found at location: C: \ Program Files (x86) \ Jaspersoft \ iReport-3.7.5 \ photos \ clob46: 'ICONE3.png'
[EDIT 1]
My method looks like this:
public void relatorio ( String codigo ){
String arquivo = null;
try{
conn = ConnectionFactory.getConnection();
arquivo = System.getProperty("user.dir") + "/src/relatorio/rel_cadastro.jrxml";
//System.out.println("Caminho do arquivo jrml: "+arquivo);
JasperDesign design = JRXmlLoader.load(arquivo);
// InputStream path1 = classLoader.getResourceAsStream("/images/logo.jpg");
String foto = System.getProperty("user.dir") + "\fotos\ICONE3.png";
InputStream path = ClassLoader.getSystemResourceAsStream( foto );
JasperReport jr = JasperCompileManager.compileReport( design );
HashMap valores = new HashMap();
valores.put("CODIGO", codigo );
valores.put("imagem", path);
JasperPrint impressao = JasperFillManager.fillReport(jr,valores,conn);
JasperViewer jrViewer = new JasperViewer(impressao, false);
jrViewer.setVisible(true);
jrViewer.setDefaultCloseOperation(JasperViewer.DISPOSE_ON_CLOSE);
}
catch(JRException e){
System.out.println("Erro no relatorio: \n"+e.getMessage());
}
}