How to save compiled JasperReport as .jasper in file

I have this code. I have a jrxml file. I can create jasperReport object successfully. But I do not know how to create a jasper file from this, and I want to save the jasper in the file location in the c drive.

JasperReport jasperReport = null;
JasperCompileManager.compileReport(getResourceAsStream("Sample_Report.jrxml"));
    try {
        jasperReport = JasperCompileManager
                .compileReport("C:\\xxx.jrxml");
        System.out.println("jasper created " + jasperReport);
    } catch (Exception e) {
        e.printStackTrace();
    }
+3
source share
1 answer

The method you want to use is

JasperCompileManager.compileReportToFile("C:\\xxx.jrxml", "C:\\xxx.jasper");
+5
source

All Articles