Rutas de imagen del informe Jasper

I want to insert images in my jasper report ,swing application. All images are in one package. I want to set path for images in jasper report.That means, to set project images's paths.When the entire project location is changed, there is an exception saying no images found. Please let me know how to set the image paths.

Project structure: MyProject
|-Source Packages

under source package
|-Images // my images are in here
|-Reports // where my jasper reports are in
|-MyJFrames |

preguntado el 08 de noviembre de 11 a las 15:11

can you add more details like your project structure and exception ? -

3 Respuestas

You haven't posted many particulars, but i have ran into a similar issue when dealing with absolute/relative paths with Jasper Report.

There is a known "discomfort" or a bug (if you want to call it that way) with Jasper Report not being able to set or use relative paths to your project resources (subreports, images etc) especially if you are compiling the reports with the IREPORT designer tool.

I am working with jasper report and IREPORT 4.1.1 and every time i compile the JRXML to a .jasper file, my paths are absolute. This causes "havoc" when the whole project is moved to a different machine. In order to use relative paths to my reports i have to compile the reports via programming means i.e in my Java application. In a nutshell, the java utility method i am using reads the JRXML file and substitutes the absolute path with a relative path and then compiles the report.

Take a look at this forum, which has some different answers of how to do it.

respondido 08 nov., 11:20

Thank you and that s what I needed. - Débora

@Aash: You can accept this answer by clicking on the empty check mark A la izquierda. - basurero

I tried all those samples in my swing application. when the project is run in netbean, it works. but when the .jar is run, there is an exception net.sf.jasperreports.engine.JRException: Byte data not found at : C:\Users\Dhanu shka\file:\D:\Projects\MyBizProjects\fin\dist\SSM.jar!\Reports\background.png . also I tried sending the absolute path. but didn't work. please any one tell me how to do this in swing application - Débora

@Aash Try placing the image folder on you classpath. The way it is described here:… - Mechkov

Thanks, but in my swing application.. where my images might be in ? As… ,and its first solution , I put my images in the same folder where .jasper located.but didn't work. I m new. Would you let me know more? - Débora

I also faced the same problem as you. To solve this, use a hard coded path value. You have to create one parameter to which you can pass your image location and then use this parameter in your image expression. I found solution in this post.

respondido 17 nov., 14:13

For Images and Subreport Path is required. I am using ./ in default prompt to work from any where i kept everything in single folder. SUBREPORT_DIR Required path same if location is different for different element then you have to pass though Parameter section as Above Post. Please check his link also.

respondido 29 mar '21, 20:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.