I have always recompiled our .jasper reports on the fly before they run. But there’s no reason for me to do this. It takes forever, and it is tying up the CPU on our new production server when four of these reports are running simultaneously. There’s nothing we’re doing to the design that would make us have to do this. But it’s the only way I know how:
JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
I am trying to find out how to instantiate that JasperReport object from a .jasper file, but I’m struggling.
Any quick pointer would help, thank you in advance.
You can use the ant task
net.sf.jasperreports.ant.JRAntCompileTaskto compile all the jrxmls to .jaspers during your application build process and then use ‘JRLoader’ to load the JasperReport from the file location.