views:

34

answers:

1

Hi,

We are using jasper reports as our reporting tool. Earlier we were using relative paths for jasper files for filling report and it's working fine.

Now, we want to create a new jar for all compiled jrxmls. i.e a jar containing all .jasper files for our project.

Is there a way to access those .jasper files within a jar file while filling report. because in documentation, i always see

fillReport(java.lang.String sourceFileName, java.util.Map params)

where, sourcefile is always a path on filesystem.

My question is, is there a way to access compiled .jasper files present within a jar file and fill report based on those files ?

EDIT: Essentially what is required is, i need to access .jasper files from a jar file, and then fill reports using that .jasper file and save the generated reports onto a filesystem.

+1  A: 

Most APIs worth using will provide overloaded methods to accept InputStreams. E.G. JasperFillManager.fillReport(InputStream, Map)

To get in InputStream, use Class.getResourceAsStream().

Andrew Thompson